{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

終於成功了.

摘抄


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM