报错信息
redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
解决方式
redis.conf配置文件中设置了密码,这里连接redis却没有加密码,需要加密码
1.使用jedis.auth()方法
public void testJedis(){
//1.连接redis
Jedis jedis = new Jedis("rhel", 6379);
//2.设置密码
jedis.auth("redispass");
//3.操作redis
jedis.set("name","zhangsan");
String name = jedis.get("name");
System.out.println(name);
//4.关闭连接
jedis.close();
}
2.注释掉配置文件中的密码
#找到自己的redis.conf配置文件目录,编辑注掉密码,不使用jedis.auth()方法也可以连接redis
vim redis.conf
#requirepass redispass
本文介绍了在使用Jedis连接Redis时遇到的AuthenticationRequired报错,提供了两种解决方案:一是通过jedis.auth()方法添加密码,二是注释掉配置文件中的密码。
7143

被折叠的 条评论
为什么被折叠?



