首先,需要你進入你的Redis解壓根目錄,例如,類似於我下圖的這樣子:
接着打開你的cmd,使用cd命令切換到該目錄,或者直接在上圖的地址欄輸入“cmd”並回車。這里為什么讓你先使用資源管理器找到你的Redis解壓根目錄呢?目的是為了讓你快速打開該目錄下的提示符。在cmd中輸入如下代碼,並按回車:
安裝Redis服務
redis-server --service-install redis.windows.conf --loglevel verbose --service-name RedisServer6379
其中,RedisServer6379為你要安裝成的服務名稱。
當返回,“[9760] 26 Sep 11:06:35.397 # Granting read/write access to 'NT AUTHORITY\NetworkService' on: "C:\Users\Raodi\Desktop\Redis3.2\Redis" "C:\Users\Raodi\Desktop\Redis3.2\Redis\" [9760] 26 Sep 11:06:35.400 # Redis successfully installed as a service.”
表示服務安裝成功! 可以打開服務控制面板查看,並可以啟動它:
卸載Redis服務
在Redis解壓目錄根目錄中,使用命令行輸入如下語句:
redis-server --service-uninstall redis.windows.conf --loglevel verbose --service-name RedisServer6379
不過前提是,先在服務控制面板中關掉你的Redis后台服務,關掉“正在運行”!!
當返回,“[25460] 26 Sep 11:09:00.822 # Redis service successfully uninstalled.”表示該服務已經被卸載了,你也可以在安裝的時候額外配置系統環境變量,這里我便省略!