1 c = redisConnect((char*)redis_host, redis_port);
 2 if (c->err) {    /* Error flags, 0 when there is no error */
 3 printf("连接Redis失败: %s\n", c->errstr);
 4 exit(1);
 5 }
 6 else
 7 {
 8 printf("连接Redis成功!\n");
 9 }
10 
11 reply = (redisReply *)redisCommand(c, "AUTH %s", redis_password);
12 if (reply->type == REDIS_REPLY_ERROR) {
13 printf("Redis认证失败!\n");
14 }
15 else
16 {
17 printf("Redis认证成功!\n");
18 }
19 freeReplyObject(reply);

就是在正常连接服务后加上auth命令传入密码

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2018-06-18
  • 2022-12-23
  • 2021-07-31
猜你喜欢
  • 2021-06-21
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
相关资源
相似解决方案