1、认证连接
// 在配置文件中找到以下配置项,大约在第 `500` 行
shell> vi /etc/redis/6379.conf
requirepass mypassword
mypassword 就是密码了,更改好后重启服务
使用设置好的密码认证
// 使用 auth 进行密码认证
127.0.0.1:6379> info
NOAUTH Authentication required.
127.0.0.1:6379> auth mypassword
OK
127.0.0.1:6379> info
# Server
redis_version:4.0.10
...略...
或者在 shell 命令行里使用 -a 选项指定密码,会出现警告信息
[root@localhost ~]# redis-cli -a foobared info
Warning: Using a password with '-a' option on the command line interface may not be safe.
# Server
redis_version:4.0.10
...略...