Could not connect to Redis at 127.0.0.1:6379: Connection refused

平时登录本机的redis的时候遇到以下情况:

[root@centoszang ~]# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
[root@centoszang ~]#

 原因在于:redis服务端没有启动成功,需要先开启服务端。

如何开启服务端?

在redis的配置文件redis-conf(其中配置了很多redis运行时的信息)中进行配置。方法:打开redis安装目录下的redis.conf文件进行编辑。如下(我将redis安装在了/opt目录):

1.将redis.conf中的daemonize no改为:daemonize yes。如下:

下面这句话的意思是:默认情况下,redis不作为守护进程运行。如果你需要的话,用yes。

 2.开启客户端。

cd src #进入redis安装目录下的src目录

 执行此目录下的redis-server:

./redis-server /opt redis-4.0.2/redis.conf

 3.登录redis:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值