一、 下载Redis
Redis 支持 32 位和 64 位。这个需要根据你系统平台的实际情况选择,这里我们下载 Redis-x64-xxx.zip压缩包到 C 盘,解压后,将文件夹重新命名为 redis。
二、安装Redis
打开一个 cmd 窗口 使用cd命令切换目录到 C: edis 运行 redis-server.exe redis.windows.conf 。
如果想方便的话,可以把 redis 的路径加到系统的环境变量里,这样就省得再输路径了,后面的那个 redis.windows.conf 可以省略,如果省略,会启用默认的。输入之后,会显示如下界面:
表示启动成功了
三、设置Redis服务
由于上面虽然启动了redis,但是只要一关闭cmd窗口,redis就会消失。所以要把redis设置成windows下的服务。
也就是设置到这里,首先发现是没用这个Redis服务的。
设置服务命令
redis-server --service-install redis.windows-service.conf --loglevel verbose
输入命令之后没有报错,表示成功了,刷新服务,会看到多了一个redis服务。
四、常用的redis服务命令
卸载服务:redis-server --service-uninstall
开启服务:redis-server --service-start
停止服务:redis-server --service-stop
启动服务 》》》
五、测试 Redis
六、安全设置(设置密码)
在redis的安装目录下找到redis.windows-service.conf文件打开
找到修改密码这一段
################################## SECURITY ################################### # 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 foobared
加上这么一行:
# requirepass foobared
requirepass yourpassword //此处注意,行前不能有空格
重新启动Redis,密码生效
重新设置密码后,重新登录才能获取操作权限
redis-cli.exe -h 127.0.0.1 -p 6379 -a 123456 //需添加密码参数
#或者
redis-cli.exe
auth "密码" // 授权