一、临时设置密码
获取密码 config get requirepass 设置密码 config set requirepass 123456 当有密码的时候登录时需要密码登录 auth 密码 取消密码 config set requirepass ''
设置好密码
此时登录不输密码会报错
二、永久设置密码
到配置文件中设置,如果不需要密码,去掉注释掉下面一行即可
requirepass 密码
三、Redis 服务设置密码
windows下修改了密码,而且重启了几次redis服务,但是发现没有效果,还是123456。
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>
123456 又是哪里来的呢? 原来123456 是redis服务 默认的密码。而Redis 服务 是不同的配置文件:
因此,我们需要修改redis.windows-service.conf, 并重启。千万注意啊