2025最新版在Windows上安装Redis(仅限开发环境)
使用一位GitHub的博主做的Redis-Windows,截止现在更新到8.0.2
Releases · redis-windows/redis-windows · GitHub
https://github.com/redis-windows/redis-windows/releases
我使用6.2.18版本做例子,使用6.2+以上版本,因为一些语法,比如lpop,rpop,zrange,zdiff集合操作比旧版有出入,旧版会报语法错误
找到6.2.18,下载msys2-with-service下载,该版本能够注册系统服务
文件名 | 适用场景 | 特点 |
---|---|---|
Redis-6.2.18-Windows-x64-msys2.zip | 开发者测试环境 | 基础功能完整,需手动启动 (redis-server.exe ) |
Redis-6.2.18-Windows-x64-msys2-with-Service.zip | 开发者测试环境 | 包含 Windows 服务支持,可后台运行 (安装后自动注册为系统服务 ) |
Redis-6.2.18-Windows-x64-cygwin.zip | 兼容性测试环境 | Cygwin 环境编译,可能与其他软件冲突 |
Redis-6.2.18-Windows-x64-cygwin-with-Service.zip | 旧系统兼容需求 | Cygwin + 服务支持,仅当 MSYS2 版本无法运行时选用 |
下载解压后移动到自己的想放置Redis的目录下,比如我的在D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service
按照github上的原博主,你可以点击start.bat手动启动redis
或者注册系统服务
使用Win + X → 命令提示符(管理员)打开终端,进入 Redis 安装目录
cd /d D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service
参考GitHub原博主的说明,输入命令
sc.exe create Redis binpath=替换成你自己的电脑路径 start= auto
sc.exe create Redis binpath=替换成你自己的电脑路径 start= demand
auto表示开机自启,demand则是需要手动在cmd输入命令net start redis 启动
sc.exe create Redis binpath=D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service\RedisService.exe start= demand
注册命令我也可以改成使用这条,不过比较长,注意修改路径
sc create Redis binPath= "\"D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service\RedisService.exe\" -service-run \"D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service\redis.conf\"" start= auto DisplayName= "Redis"
sc create Redis binPath= "\"D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service\RedisService.exe\" -service-run \"D:\developp\Redis-6.2.18-Windows-x64-msys2-with-Service\redis.conf\"" start= demand DisplayName= "Redis"
注册后输入命令启动
net start Redis
如果想要结束命令,输入命令net stop redis结束服务
net stop redis
如果端口冲突,修改redis.conf
打开任务管理器的资源监视器可以看到6379端口启动的redis-server
删除服务使用sc delete redis
sc delete redis