【排错日记】redis连接错误:ERR Client sent AUTH, but no password is set

当客户端使用Redis时,如果在配置中启用了auth认证但未设置密码,会导致连接失败。解决方法包括在Redis配置文件中取消密码验证,或者在客户端配置中删除password字段。此外,还可以通过自定义配置类,在客户端代码中覆盖并处理密码设置,例如使用Redisson客户端动态设置密码。
摘要由CSDN通过智能技术生成

本质原因

​ 客户端设置了auth认证,但没设置密码。参考:https://blog.csdn.net/quanaianzj/article/details/84621743

解决方案

  1. redis配置文件去掉密码校验。
    requirePass: 你的密码
    
  2. 客户端配置文件中去掉password所在行。
  3. 客户端覆写配置类,单独处理password。

    如:

    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() {
        Config config = new Config();
        ClusterServersConfig clusterServersConfig = config.useClusterServers();
        clusterServersConfig.addNodeAddress(this.redisProperties.getCluster().getNodes().stream()
                                            .map(node -> "redis://" + node).toArray(x$0 -> new String[x$0]));
        if (StringUtils.isNotBlank(this.redisProperties.getPassword())) {
          clusterServersConfig.setPassword(this.redisProperties.getPassword());
        }
        return Redisson.create(config);
    }
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值