天天看點

SpringBoot項目連接配接Redis:ERR Client sent AUTH, but no password is set問題原因解決

問題

SpringBoot項目連接配接Redis報錯:

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR Client sent AUTH, but no password is set
    at redis.clients.jedis.Protocol.processError(Protocol.java:127)
    at redis.clients.jedis.Protocol.process(Protocol.java:161)
    at redis.clients.jedis.Protocol.read(Protocol.java:215)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:340)
    at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:239)
    at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2139)
    at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:108)
    at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:874)
    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:417)
    at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:346)
    at redis.clients.util.Pool.getResource(Pool.java:49)      

原因

問題也很明顯:Redis伺服器沒有設定密碼,但用戶端向其發送了AUTH(authentication,身份驗證)請求。

解決

方法一:去掉配置項裡的password

将配置中的password注釋掉

SpringBoot項目連接配接Redis:ERR Client sent AUTH, but no password is set問題原因解決

方法二:給Redis服務端設定密碼

第二種是給Redis Server設定密碼,并且用戶端配置正确的密碼。

可以通過指令行修改密碼:

config set requirepass 123456      

也可以通過修改配置檔案來修改密碼,redis.windows.conf配置檔案,搜尋requirepass,找到注釋密碼行,去掉注釋,設定密碼:

requirepass tenny     //注意,行前不能有空格