{Redis}NOAUTH Authentication required. Linux.cenOS

问题

[root@VM_0_12_centos redis]# ./bin/redis-cli -p 6379
127.0.0.1:6379> INFO
NOAUTH Authentication required.

解决方案.简述版本(推荐)

0.我所用到的命令集合


#先用最通用的命令,大部分的人的问题应该就是可以解决的.
[root@VM_0_12_centos redis]# ./bin/redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> AUTH 你的密码

#敬酒不吃吃罚酒的话,先找到进程ID(pid),然后kill即可
[root@VM_0_12_centos redis]# pgrep redis
31311
[root@VM_0_12_centos redis]# kill -9 31311

#启动服务,继续使用{AUTH}看看是否可以了.
[root@VM_0_12_centos redis]# ./bin/redis-server redis.conf
12557:C 06 Dec 2019 13:53:11.387 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12557:C 06 Dec 2019 13:53:11.387 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=12557, just started
12557:C 06 Dec 2019 13:53:11.387 # Configuration loaded

[root@VM_0_12_centos redis]# ./bin/redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> INFO
NOAUTH Authentication required.
127.0.0.1:6379> AUTH 123456
OK

解决方案.详细过程(比较啰嗦)

1.解决方案.AUTH 你的密码



[root@VM_0_12_centos redis]# ./bin/redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> AUTH 123456
(error) ERR invalid password
127.0.0.1:6379> AUTH "123456"
(error) ERR invalid password
127.0.0.1:6379> AUTH '123456'
(error) ERR invalid password


这一步骤是网上最多的解决方案,
我后来也是用这个方式解决的.
只不过有些原因,导致我第一次使用这个方法的时候并没有效果.

2."(error) ERR invalid password"

线索到了"(error) ERR invalid password"这个提示语就断了.
我准备搜索下这个提示会不会给我带来惊喜.

3.思考原因

明明别人一条语句就可以"OK"的问题,
为啥我搞起来这么曲折.
网上搜索还说到过:可能是被黑了...
经过我仔细想了想我对{Redis}做过的,
有一个操作对这个影响确实很大:
我频繁了改过{redis.conf}中密码配置项{requirepass}.

我决定重启{Redis}服务...
再不行就重启{Linux}...

4.重启Redis服务

任何事情第一次搞起来总是曲折重重...

4.1. Redis的shutdown命令关闭服务,然后启动服务


[root@VM_0_12_centos redis]# redis-cli -p 6397 shutdown
Could not connect to Redis at 127.0.0.1:6397: Connection refused

很明显,失败了...也懒着再找这个失败的原因了.
搜索下其它重启服务的方式...
最后选择了简单粗暴型:kill

4.2 kill

我想先启动一下服务,然后在kill掉.
结果杀错了进程...


#启动你只是为了kill你...
[root@VM_0_12_centos redis]# ./bin/redis-server redis.conf
11448:C 06 Dec 2019 13:41:19.532 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11448:C 06 Dec 2019 13:41:19.532 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=11448, just started

启动完之后我看了"pid=11448"...
我当时心里想:这就是那个倒霉蛋?
一个"just started"就要被"kill"的进程?

[root@VM_0_12_centos redis]# kill 11448
-bash: kill: (11448) - No such process

不好意思,认错进程了...

但是没关系,我又听说可以"kill -9"比较好使..值得一试...

[root@VM_0_12_centos redis]# kill -9
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

还是没关系,我再去搜索如何找到你,再去kill你...

[root@VM_0_12_centos redis]# ps -ef|grep redis
root     11793 10456  0 13:45 pts/0    00:00:00 grep --color=auto redis
root     31311     1  0 Nov26 ?        00:12:26 ./bin/redis-server *:6379
[root@VM_0_12_centos redis]# kill 31311
#再次执行ps -ef|grep 看看有没有成功...
[root@VM_0_12_centos redis]# ps -ef|grep redis
root     11793 10456  0 13:46 pts/0    00:00:00 grep --color=auto redis
root     31311     1  0 Nov26 ?        00:12:26 ./bin/redis-server *:6379

很明显,又失败了...
首先我对于"31311"是否是redis的pid,保持怀疑态度.
并且如果是的话,那"11793 10456"pid又是什么鬼?

我决定换个命令,能明确告诉我{redis.pid}是什么...

[root@VM_0_12_centos redis]# pgrep redis
31311

这下可以了,找到正主了"31311"...

[root@VM_0_12_centos redis]# kill 31311
[root@VM_0_12_centos redis]# redis-cli
127.0.0.1:6379> INFO
NOAUTH Authentication required.
127.0.0.1:6379> AUTH 123456
(error) ERR invalid password

又失败了...是时候探索下"kill -9"的用法了...

[root@VM_0_12_centos redis]# kill -9 31311
[root@VM_0_12_centos redis]# ps -ef|grep redis
root     12196 10456  0 13:51 pts/0    00:00:00 grep --color=auto redis

[root@VM_0_12_centos redis]# ./bin/redis-server redis.conf
12557:C 06 Dec 2019 13:53:11.387 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12557:C 06 Dec 2019 13:53:11.387 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=12557, just started
12557:C 06 Dec 2019 13:53:11.387 # Configuration loaded

[root@VM_0_12_centos redis]# ./bin/redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> INFO
NOAUTH Authentication required.
127.0.0.1:6379> AUTH 123456
OK

终于成功了.

摘抄

原文地址:https://www.cnblogs.com/love-zf/p/12002176.html