远程登录 Redis 服务,远程停止 Redis 服务,远程登录redis
远程登录 Redis 服务,远程停止 Redis 服务
先启动 Redis 服务,打开一个命令窗口,启动 Redis 服务。
D:\Redis>redis-server.exe redis.windows.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.500 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8828
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[8828] 19 May 14:35:58.254 # Server started, Redis version 3.0.500
[8828] 19 May 14:35:58.256 * DB loaded from disk: 0.001 seconds
[8828] 19 May 14:35:58.258 * The server is now ready to accept connections on port 6379
1. 远程链接 Redis 服务
打开一个命令窗口,远程链接 Redis 服务:
D:\Redis>redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
用 ping 命令不通,提示身份验证,用 auth 命令 + 密码 进行验证身份:
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> ping
PONG
也可以在链接服务时直接用 -a 参数进行身份验证:
D:\Redis>redis-cli.exe -h 127.0.0.1 -p 6379 -a 123456
127.0.0.1:6379> ping
PONG
2. 远程关闭 Redis 服务
D:\Redis>redis-cli.exe -h 127.0.0.1 -p 6379 -a 123456 shutdown
D:\Redis>
再看服务端窗口,Redis 服务已经退出:
D:\Redis>redis-server.exe redis.windows.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.500 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 8828
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[8828] 19 May 14:35:58.254 # Server started, Redis version 3.0.500
[8828] 19 May 14:35:58.256 * DB loaded from disk: 0.001 seconds
[8828] 19 May 14:35:58.258 * The server is now ready to accept connections on po
rt 6379
[8828] 19 May 14:37:19.665 # User requested shutdown...
[8828] 19 May 14:37:19.665 * Saving the final RDB snapshot before exiting.
[8828] 19 May 14:37:19.674 * DB saved on disk
[8828] 19 May 14:37:19.675 # Redis is now ready to exit, bye bye...
D:\Redis>