Redigo: redis 3.0版本redis用密码连接不上,3.2版本没问题,是不是不兼容?

创建于 2018-08-29  ·  4评论  ·  资料来源: gomodule/redigo

我使用 newPool 来初始化 redis.Pool

var (
    Pool *redis.Pool
)

func newPool(server string) *redis.Pool {
    return &redis.Pool{
        MaxIdle:     3,
        IdleTimeout: 240 * time.Second,
        Dial: func() (redis.Conn, error) {
            redisPwd, _ := misc.AppConf.Get("redis_pwd")  // get password from config

            conn, err := redis.Dial("tcp", server, redis.DialPassword(redisPwd))
            if err != nil {
                return nil, err
            }
            return conn, nil
        },
        TestOnBorrow: func(c redis.Conn, t time.Time) error {
            _, err := c.Do("PING")
            return err
        },
    }
}

尝试连接redis DB

func TestRedis(t *testing.T) {
    InitRedis()

    redisConn := Pool.Get()

    keys, err := redis.Strings(redisConn.Do("kEYS", "*"))
    if err != nil {
        t.Fatal(err)
    }

    fmt.Printf("%v\n", keys)

    time.Sleep(time.Hour)
}

连接3.0版本redis DB时返回错误: ERR Client sent AUTH, but no password is set

最有用的评论

没有设置密码

您是否在配置文件中设置了密码,服务器是否使用了该配置文件?

所有4条评论

错误消息描述了问题。 跳过发送密码或在服务器的配置中设置密码。

@garyburd我也有同样的问题。 我已经在redis.windows.conf中设置了requirepass $ 并使用该配置运行redis.exe 。 当我进行池连接时,它说: Redis set failed: ERR Client sent AUTH, but no password is set

没有设置密码

您是否在配置文件中设置了密码,服务器是否使用了该配置文件?

没有设置密码

你在配置文件中设置了密码吗?

对不起这是我的错。 我混淆了我的两个 Redis 服务器。 现在一切正常。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

mika picture mika  ·  5评论

V2Vz picture V2Vz  ·  4评论

lukasmalkmus picture lukasmalkmus  ·  18评论

garyburd picture garyburd  ·  23评论

Serhioromano picture Serhioromano  ·  7评论