Linux下redis设置密码不生效的原因

前因:

我一直使用命令行的方式设置密码

127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass "123456"
OK

然后我就shutdown关闭redis
然后关闭服务器

127.0.0.1:6379> shutdown
not connected> 

开启服务器(一定要在根目录开启)

[root@VM-16-15-centos bin]# redis-server myredisconfig/redis.conf
12295:C 27 Oct 2021 10:16:42.271 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12295:C 27 Oct 2021 10:16:42.271 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=12295, just started

后来发现根本没生效。

正文:然后使用了直接改conf配置文件的方法:

先进入你用来生效的配置文件:(我的文件名叫myredisconfig)

[root@VM-16-15-centos bin]# cd myredisconfig/
[root@VM-16-15-centos myredisconfig]# vi redis.conf

然后找到
然后下一步先去开启redis**(记住这里的参数一定要选你刚改的配置conf,不然就是redis默认的了)**

[root@VM-16-15-centos bin]# redis-server myredisconfig/redis.conf
12821:C 27 Oct 2021 10:20:27.013 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12821:C 27 Oct 2021 10:20:27.013 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=12821, just started
12821:C 27 Oct 2021 10:20:27.013 # Configuration loaded


然后开启客户端验证:发现可以了

[root@VM-16-15-centos bin]# redis-cli -p 6379
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> 

也可以在idea中用jedis验证一下试试:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值