广告
返回顶部
首页 > 资讯 > 服务器 >(error) DENIED Redis is running in protected mode because protected mode is enabled and no password
  • 878
分享到

(error) DENIED Redis is running in protected mode because protected mode is enabled and no password

redis服务器 2023-09-12 15:09:22 878人浏览 泡泡鱼
摘要

报错信息 (error) DENIED Redis is running in protected mode because protected mode is enabled and no passWord is set for th

报错信息


(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进行操作

解决办法

(1)修改redis.conf文件,让redis关闭保护模式或者给redis设置登录密码

【1】第一种方法是:关闭保护模式

保护模式默认开启:

 

 修改成关闭:

 

【2】第二种方法:给redis设置登录密码(我个人建议用这一种方法)

 

(2)重启redis服务,让配置生效(因为redis认为远程连接不安全,阻止我对redis进行操作,对redis输入的任何命令都会报错,所以也不能对redis使用shutdown命令来进行关机,这时就需要我们强行给redis终止进程)

【1】查看redis的进程id

ps -ef | grep redis

 【2】把redis的进程干掉

kill -9 进程id

例:

【3】重新启动redis服务

redis-server redis.conf

效果图:

 

【4】登录redis,进入命令行操作界面(如果是设置密码需要加上-a,如果只是关掉保护模式则不需要加上-a)

redis-cli -h IP地址 -p 端口号 -a 密码

例:

 【5】再次测试不再报错

效果图:

来源地址:https://blog.csdn.net/m0_64284147/article/details/125682121

--结束END--

本文标题: (error) DENIED Redis is running in protected mode because protected mode is enabled and no password

本文链接: https://www.lsjlt.com/news/404739.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作