redis用户验证

1配置密码认证功能

vim /opt/redis_6379/conf/redis_6379.conf

requirepass 123456

 

2使用密码登陆

方式1:

[root@elk101 ~]# redis-cli
127.0.0.1:6379> set k1 v1
(error) NOAUTH Authentication required.
127.0.0.1:6379> AUTH 123456
OK
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> KEYS *
1) "k1"

 

方式2:

[root@elk101 ~]# redis-cli -a '123456' get k1
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
"v1"

 

posted on 2021-07-05 13:54  弓长三寿  阅读(200)  评论(0编辑  收藏  举报