1.下载windows版本Redis,如Redis-x64-5.0.14.zip
2.解压到任意目录,如F:\qc-development\Redis5.0.14
3.(非必要)修改redis配置文件redis.windows.conf,如修改端口号为6380
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6380
4.cmd进入到安装目录(F:\qc-development\Redis5.0.14),注册为windows服务
使用默认配置文件注册,输入命令:
redis-server --service-install
使用指定配置文件注册,输入命令:
redis-server --service-install redis.windows.conf
注意:只要有修改过配置文件,都要将服务注册成使用指定配置文件注册,否则配置文件不生效。
5.启动服务
①不使用命令
Win+R 打开运行,输入services.msc,进入服务管理。找到Redis,右键启动。
②使用命令(安装目录下)
使用默认配置文件启动,输入命令:(使用这个命令,在服务管理中看到注册的Redis服务是没有启动的)
redis-server.exe
或者使用这个命令,在服务管理中启动注册的Redis服务:(在服务管理中看到注册的Redis服务是启动的)
redis-server --service-start
使用指定配置文件启动,输入命令:
redis-server.exe redis.windows.conf
注意:只要有修改过配置文件,都要使用指定配置文件启动,否则配置文件不生效。
扩展:
6.卸载Redis服务
①输入命令(安装目录下)
redis-server --service-uninstall
②删除Redis安装目录:找到Redis的安装目录,并将其完全删除。这样可以确保在重新安装时不会出现任何冲突。