1、下载 地址:https://github.com/MSOpenTech/redis/releases
点击版本号(如3.2.100)进入下载页面。
2、启动服务端 命令 redis-server.exe redis.windows.conf //需要指定配置文件
安装目录查看是否含有配置文件,如果没有,可自行下载
http://download.redis.io/redis-stable/redis.conf
3、启动客户端 命令 redis-cli.exe -h 127.0.0.1 -p 6379
第一次连接时,没有密码,因此无需填写。
4、设置密码
4.1 命令方式修改
config get requirepass #获取当前密码
config set requirepass "new_password" #设置密码!服务重启后失效。
4.2 配置文件修改
安装目录找到配置文件(文件名类似 redis.conf、redis.windows.conf)搜索 requirepass 关键字 解除注释,添加新的密码
# requirepass foobared
requirepass new_password #此处注意,行前不能有空格
保存后,重启服务端才能生效。
重新连接redis的命令为
redis-cli.exe -h 127.0.0.1 -p 6379 -a 123456 #需添加密码参数