鏈接服務器的Redis(由於遠程連接不上,使用服務器連接,也連接不上產生)
Unable to connect to remote host: Connection refused
鏈接不上,有可能是服務沒有對外開放。
1.修改redis配置:redis.conf.
路徑:/usr/local/src/redis-5.0.5/etc
2、修改密碼:
a、登陸之后(臨時修改)
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
為以上顯示說明沒有密碼,那么現在來設置密碼:
127.0.0.1:6379> config set requirepass abcdefg
OK
127.0.0.1:6379>
再次查看當前redis就提示需要密碼:
127.0.0.1:6379> config get requirepass
(error) NOAUTH Authentication required.
127.0.0.1:6379>
這是可以輸入 auth 密碼
即可
b、修改redis.conf配置文件(永久)
# requirepass foobared
requirepass 123 指定密碼123
保存后重啟redis就可以了
3、重啟redis
由於本人使用shutdown無法停止redis服務,所以采用ps -ef|grep redis ,kill掉目前的redis服務。
再使用./src/redis-cli -h 指定ip -p 指定端口 -a 指定密碼 啟動redis
或是使用:/usr/local/src/redis-5.0.5/bin/redis-server /usr/local/src/redis-5.0.5/etc/redis.conf 啟動
4、查看所有值
keys *