Redis报错:(error) DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user
一、报错内容
(error) DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
翻译结果
(错误)DENIED Redis正在保护模式下运行,因为启用了保护模式,并且没有为默认用户设置密码。在此模式下,只接受来自环回接口的连接。如果您想从外部计算机连接到Redis,您可以采用以下解决方案之一:1)只需通过从服务器运行的同一主机连接到Redis,从环回接口发送命令“CONFIG SET protected mode no”即可禁用受保护模式,但是,如果这样做,请确保不能从互联网公开访问Redis。使用配置重写将此更改永久化。2) 或者,您可以通过编辑Redis配置文件,将保护模式选项设置为“否”,然后重新启动服务器来禁用保护模式。3) 如果只是为了测试而手动启动服务器,请使用“-protected mode no”选项重新启动服务器。4) 为默认用户设置身份验证密码。注意:您只需要执行上述操作之一,服务器就可以开始接受来自外部的连接。
二、报错原因:
redis认为远程连接不安全,所以阻止你对redis进行操作
三、解决办法
3.1 修改配置
3.1.1 第一种方法是:关闭保护模式
[root@localhost redis-v7.0.5]# vi conf/redis.conf
# 修改保护模式为no,默认为 yes protected-mode no
3.1.2 方式二:添加密码访问
[root@localhost redis-v7.0.5]# vi conf/redis.conf # 手动添加以下内容 requirepass wangzy@123
3.2 重启服务
# 我这里用的是docker启动,故只要重启容器就好
docker restart 容器id
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)