redis在.Net程序中使用

1.设置访问密码
config set requirepass 123456 

 

2.连接redis服务器
 private static string redisHost = ConfigHelper.GetAppSetting("redisHost");
 private static int redisPort = ConfigHelper.GetAppSetting("redisPort").AsInt32();
 private static string redisPass = ConfigHelper.GetAppSetting("redisPass");
 private static RedisClient redis = new RedisClient(redisHost, redisPort, redisPass);

 

可能遇到的问题:
1.如果报如下错误:
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode
可能就是因为没有设置访问密码
 
2.如果无法连接redis服务器,可能是因为端口的问题:
/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
 如果都设置好了还报错,稍等一会即可
 
3.NOAUTH Authentication required.
auth 123456:重新设置访问密码即可

转载于:https://www.cnblogs.com/hpp3501/p/5984293.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值