Ubuntu on Win10
- 安裝
首先,需要輸入以下內容來安裝redis-server:
sudo apt-get install redis-server
接下來,要編輯/etc/redis/redis.conf并將以下行
bind 127.0.0.1
更改為
bind 0.0.0.0
最后,鍵入以下命令重新啟動服務:
sudo service redis-server restart
- 測試
接下來,可以通過輸入以下內容來測試你的Redis服務器實例:
root@yan:/home/yan# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
- redis服務自啟動問題
關閉Ubuntu窗口后下次再打開,redis-cli連不上redis服務器:
yan@yan:~$ redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
解決方法:
yan@yan:~$ sudo service redis-server start
[sudo] password for yan:
Starting redis-server: redis-server.
yan@yan:~$
再次測試:
yan@yan:~$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set hello world
OK
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379>
好像……WSL里面每次都要自己手動啟動服務……