一、设置方法:
方法一:通过命令设置密码(临时生效,重启服务器后密码失效)
使用redis-cli连接上redis,执行如下命令:
config set requirepass 123456
执行完毕,无需重启,退出客户端,重新登录就需要输入密码了
方法二:通过配置文件redis.conf设置密码(永久生效)
vi编辑器打开redis.conf
[root@localhost /]# vi /etc/redis.conf
输入/requirepass 找到requirepass关键字,后面跟的就是密码,默认是注释掉的,即不需要密码
# The requirepass is not compatable with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.