Redis报错:DENIED Redis is running in protected mode
转:Redis使用认证密码登录
Redis默认配置是不需要密码认证的,也就是说只要连接的Redis服务器的host和port正确,就可以连接使用。这在安全性上会有一定的问题,所以需要启用Redis的认证密码,增加Redis服务器的安全性。
1. 修改配置文件
Redis的配置文件默认在/etc/redis.conf
,找到如下行:
#requirepass foobared
去掉前面的注释,并修改为所需要的密码:
requirepass myPassword (其中myPassword就是要设置的密码)
2. 重启Redis
如果Redis已经配置为service
服务,可以通过以下方式重启:
service redis restart
如果Redis没有配置为service
服务,可以通过以下方式重启:
/usr/local/bin/redis-cli shutdown
/usr/local/bin/redis-server /etc/redis.conf
3. 登录验证
设置Redis认证密码后,客户端登录时需要使用-a
参数输入认证密码,不添加该参数虽然也可以登录成功,但是没有任何操作权限。如下:
$ ./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
使用密码认证登录,并验证操作权限:
$ ./redis-cli -h 127.0.0.1 -p 6379 -a myPassword
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "myPassword"
看到类似上面的输出,说明Reids密码认证配置成功。
除了按上面的方式在登录时,使用-a
参数输入登录密码外。也可以不指定,在连接后进行验证:
$ ./redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> auth myPassword
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "myPassword"
127.0.0.1:6379>
4. 在命令行客户端配置密码(redis重启前有效)
前面介绍了通过redis.conf
配置密码,这种配置方式需要重新启动Redis。也可以通命令行客户端配置密码,这种配置方式不用重新启动Redis。配置方式如下:
127.0.0.1:6379> config set requirepass newPassword
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "newPassword"
注意:使用命令行客户端配置密码,重启Redis后仍然会使用redis.conf
配置文件中的密码。
5. 在Redis集群中使用认证密码
如果Redis服务器,使用了集群。除了在master
中配置密码外,也需要在slave
中进行相应配置。在slave
的配置文件中找到如下行,去掉注释并修改与master
相同的密码即可:
# masterauth master-password
文章转自:http://itbilu.com/linux/management/Ey_r7mWR.html
Redis报错:DENIED Redis is running in protected mode的更多相关文章
- docker启动redis报错 oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
docker启动redis报错 1:C 17 Jun 08:18:04.613 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo1:C 17 Jun 08 ...
- Redis报错:redis.exceptions.ResponseError: MISCONF Redis is configured to save RDB snap
首先找到出现错误的原因: redis.exceptions.ResponseError: MISCONF Redis is configured to save RDB snapshots, but ...
- redis报错MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist
解决方法:通过redis-cli连接到服务器后执行以下命令: config set stop-writes-on-bgsave-error no 注意:这种方法只是忽略了问题,并没有解决问题,具体问题 ...
- 2017.7.10 Redis报错:DENIED Redis is running in protected mode
参考来自: java 客户端链接不上redis解决方案 DENIED Redis is running in protected mode 完整错误信息: Caused by: redis.clien ...
- 使用Lua 脚本实现redis 分布式锁,报错:ERR Error running script (call to f_8ea1e266485534d17ddba5af05c1b61273c30467): @user_script:10: @user_script: 10: Lua redis() command arguments must be strings or integers .
在使用SpringBoot开发时,使用RedisTemplate执行 redisTemplate.execute(lockScript, redisList); 发现报错: ERR Error run ...
- mac brew install redis 报错
mac brew install redis 报错 /usr/local/opt/php55/bin/phpize /usr/local/opt/php55/bin/phpize: line 61: ...
- redis报错Windows error 0x70(a large memory)
redis报错Windows error 0x70 redis 嫌弃你内存不够了,就给你不开第二个实例. The Windows version of Redis allocates a large ...
- redis 报错及解决
报错: (error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persi ...
- filebeat output redis 报错 i/o timeout
filebeat output redis 报错 i/o timeout 先把报错内容贴出来. ERROR redis/client. go: Failed to RPUSH to redis li ...
- window下安装redis报错: creating server tcp listening socket 127.0.0.1:6379: bind No error
window下安装redis报错: creating server tcp listening socket 127.0.0.1:6379: bind No error 解决: 如果没有配置环境,在安 ...
随机推荐
- Python 中的闭包和自由变量
1.定义 在函数内部再定义一个函数,并且这个函数用到了外部函数的变量(LEGB),最后返回新建函数的函数名索引,那么将这样的能够访问其定义时所在的作用域的函数以及用到的一些变量称之为闭包.被引用的非全 ...
- C#中String StringBuilder
String和StringBuilder和StringBuffer,这三个都是值得深究一翻的,可能很多人会说,实在不行的话,都全部用StringBuilder,啥事没有,我不能说你的想法事不正确的,但 ...
- HTML学习如何布局
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>菜鸟 ...
- python post请求中Content-Typ为application/x-www-form-urlencoded; charset=UTF-8 解决方案
# -*- coding: utf-8 -*- import requests import json from urllib import parse import quotes def GtgLo ...
- mysql什么时候会发生file sort
看了网上很多排名很靠前的博客,发现好多都讲错了!我开始按照博客来,没有怀疑,直到自己试了一下才发现是错的. file sort在面试中有时候会问到,这个其实挺能区分是不是真的了解order by的执行 ...
- 记一次NAS故障分析(ZFS NFS)
问题: 使用vdbench进行单层100w目录,每个目录30个文件,共3000w文件读写时,在创建文件得时候IO会出现断断续续得情况. 分析过程: 1. nfs抓包分析 使用vdbench创建一个文 ...
- 如何使用 VS Code 远程连接矩池云主机
Visual Studio Code(以下简称 VS Code)是一个由微软开发的代码编辑器.VS Code 支持代码补全.代码片段.代码重构.Git 版本控制等功能. VS Code 现已支持连接远 ...
- CLR的GC工作模式介绍(Workstation和Server)
CLR的核心功能之一就是垃圾回收(garbage collection),关于GC的基本概念本文不在赘述.这里主要针对GC的两种工作模式展开讨论和研究. Workstaction模式介绍 该模式设计的 ...
- think php jq ajax删除
表单展示页面 <!doctype html> <html lang="en"> <head> <meta charset="UT ...
- 关于php接受xml的一些问题,simplexml_load_string收不到数据
接受xml数据一般使用这两种方法 方法1: file_get_contents('php://input'); 方法2: simplexml_load_string($GLOBALS['HTTP_RA ...