问题
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注释掉
方法二:给Redis服务端设置密码
第二种是给Redis Server设置密码,并且客户端配置正确的密码。
可以通过命令行修改密码:
config set requirepass 123456
也可以通过修改配置文件来修改密码,redis.windows.conf配置文件,搜索requirepass,找到注释密码行,去掉注释,设置密码:
requirepass tenny //注意,行前不能有空格