Ubuntu20 WSL 安装Redis 报错Connection refused
文章目录
本来想在windows上安装一个Redis,但是发现官方都没有提供预编译好的二进制发行版本,这就很让人头疼了。
那就想着在WSL上安装吧,美滋滋。
在Ubuntu20.04 WSL上安装redis有两种方式:
- 使用
apt包管理器 - 自行编译源代码
先说第一种办法,通过apt包管理器安装Redis是最方便的
只需如下两行命令即可
sudo apt update
sudo apt install redis-server但是实际上不行,你会发现一些错误:
csy@Yoga14S-yjc:~$ systemctl status redis-server
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down以及
csy@Yoga14S-yjc:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
not connected>
not connected>
not connected>
not connected>
not connected> dsa
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>这就很麻烦,为了解决Connection refused错误
可以执行一下命令
sudo service redis-server start这是便可以正常使用redis-cli了
csy@Yoga14S-yjc:~$ redis-cli
127.0.0.1:6379> exit但是输入systemctl status redis-server查看redis-server的运行状态还是不行
但是通过service命令是可以的。
csy@Yoga14S-yjc:~$ sudo service redis-server status
* redis-server is running关于service和systemctl的区别可以参考这篇文章Linux 服务管理两种方式service和systemctl
关于为什么service可以而systemctl不可以,参考这篇文章修复 "System has not been booted with systemd as init system "的错误。你就会知道答案。

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论