安装环境
- windows 10
- Redis-x64-3.0.504
Resis下载
https://github.com/MicrosoftArchive/redis/releases
安装
下载后,解压就完成了安装。
启动
E:\Tools\Redis-x64-3.0.504>redis-server.exe redis.windows.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.504 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 19908
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[19908] 24 Jun 17:06:12.931 # Server started, Redis version 3.0.504
[19908] 24 Jun 17:06:12.932 * DB loaded from disk: 0.000 seconds
[19908] 24 Jun 17:06:12.932 * The server is now ready to accept connections on port 6379
设置配置windows 启动服务
执行命令
redis-server --service-install redis.windows-service.conf --loglevel verbose
修改redis.windows-service.conf
# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output.
logfile "logs/redis_log.txt"
创建logs文件夹
服务创建成功,使用命令:services.msc
注意:如果不创建logs文件夹导致服务启动不起来。报错为:
Windows无法启动Redis服务(位于本地计算机上)。
错误1067:进程意外终止。
设置密码
修改redis.windows-service.conf
# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass password
重启启动服务即可
使用
E:\Tools\Redis-x64-3.0.504>redis-cli.exe
127.0.0.1:6379> auth password //登录
OK //登录成功
127.0.0.1:6379> config get requirepass //获取密码
1) "requirepass"
2) "password"
127.0.0.1:6379> quit //退出
E:\Tools\Redis-x64-3.0.504>redis-cli.exe -a password //登录
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "password"
127.0.0.1:6379> quit
E:\Tools\Redis-x64-3.0.504>redis-cli.exe -p 6379 -a password // 登录
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "password"
127.0.0.1:6379>