博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
解决使用jedis连接是报DENIED Redis is running in protected mode错误
阅读量:4695 次
发布时间:2019-06-09

本文共 1819 字,大约阅读时间需要 6 分钟。

DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. 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 bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

  

1. 错误原因:由于redis的保护模式开启了,并且没有绑定ip地址,没有密码认证

2. 解决方案

方案一:

1) 使用 设置CONFIG SET protected-mode no

步骤:

1. 在redis本机上打开redis-cli工具,并连接

2. 在其中输入CONFIG SET protected-mode no即可

缺点:

该种方式只是短暂性有效,如果redisServer重新启动后还是不能正常链接

方案二:

1)编辑redis配置文件,将保护模式关闭

步骤:

由于我是直接使用redis-server 命令启动的,所以说其服务是按照其默认设置进行启动,修改/usr/local/etc/redis.conf

如果没有请从下载的redis中复制一个redis.conf到这里,

将bind 后面绑定的ip后面加入你本机外网的ip

bind 127.0.0.1 192.168.21.4

  

然后保存,再使用redis-server /usr/local/etc/redis.conf启动

问题:

  1.redis-cli不能直接使用,必须输入绑定的ip+d端口号才能正常使用

  2.不安全

2). 将redis.conf中安全模式关闭

将该保护模式改为no

再试

缺点:1.保护模式关闭后不安全

3)设置密码访问模式

在redis.conf中加入一行密码设置

require 你的密码

 保存,再重新启动redis客户端

以上四种方式解决该错误都可以,但是根据上面的优缺点,

 

选择第四种方式最佳,安全性最高 

转载于:https://www.cnblogs.com/lonecloud/p/9084761.html

你可能感兴趣的文章
mini2440 U-boot 编译
查看>>
在UTF-8中,一个汉字为什么需要三个字节?
查看>>
浅谈 WPF控件
查看>>
学习ThreadLocal
查看>>
在 Visual Studio 调试器中指定符号 (.pdb) 和源文件
查看>>
直接量
查看>>
leetcode 115. 不同的子序列(Distinct Subsequences)
查看>>
三元表达式
查看>>
Go初接触之libjpeg-turbo
查看>>
python--生成器协程运算
查看>>
INFT 3030 Concurrent Programming
查看>>
小心了,这个设置会导致你的vm重启时被强制重装系统!
查看>>
邮票面值设计 (动态规划+DFS)
查看>>
解决INSTALL_FAILED_MISSING_SHARED_LIBRARY (转载)
查看>>
Linux内核高端内存
查看>>
HTML列表
查看>>
Redis集群创建报错
查看>>
DispacherServlet 的作用
查看>>
POJ - 1426(Find The Multiple)
查看>>
一张图带你看懂原始dao与SQL动态代理开发的区别-Mybatis
查看>>