使用redis遇到了 Could not connect to Redis at 127.0.0.1:6379: Connection refused 错误

遇到的问题

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

        当我们直接连接 redis 时,会遇到 Could not connect to Redis at 127.0.0.1:6379: Connection refused 这个问题,显示连接被拒绝

原因

        是因为没有启动 redis 的服务端,所以我们的 redis 连接不到他的服务,需要启动 redis 服务端

解决方法

        如下图,这是 redis 的 bin 目录,找到 redis-server 和 redis.conf 这两个文件

[root@localhost ~]# ll /usr/local/redis/bin/
总用量 16264
-rwxr-xr-x. 1 root root  708272 11月  1 00:04 redis-benchmark
-rwxr-xr-x. 1 root root 4962208 11月  1 00:04 redis-check-aof
-rwxr-xr-x. 1 root root 4962208 11月  1 00:04 redis-check-rdb
-rwxr-xr-x. 1 root root  964912 11月  1 00:04 redis-cli
-rwxr-xr-x. 1 root root   84842 11月  1 00:08 redis.conf
lrwxrwxrwx. 1 root root      12 11月  1 00:04 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 4962208 11月  1 00:04 redis-server

        我们在命令行启动这两个文件,输入 /usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf

[root@localhost ~]# /usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf

        然后启动 redis 客户端,输入 redis-cli 就可以成功了

[root@localhost ~]# redis-cli
127.0.0.1:6379>

若有不足或者不正之处,欢迎指正批评,感激不尽!如果有疑问欢迎留言,绝对第一时间回复! 

  • 8
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牧魂.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值