今天用Springboot项目去创建redis客户端的时候报错:DENIED Redis is running in protected mode
错误原因:链接redis 时只能通过本地localhost (127.0.0.1)这个来链接,而不能用网络ip(192.168.118.128)这个链接。
解决办法:
- 打开配置文件redis.conf(打开文件命令:vi redis.conf)
# bind 127.0.0.1 // 默认本地连接,注释掉后可以网络连接
- Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程,设置为no
daemonize no
- 保护模式(默认为yes,开启保护模式,因为没有设置密码,这是redis的安全模式,我们设置为no)
protected-mode no
我报这个错的原因是启动没带上配置文件
正确启动redis命令:./redis-server redis.conf (redis.conf为你目录地址)