下载
1、Github下载地址:https://github.com/microsoftarchive/redis/releases/tag/win-3.2.100
2、百度网盘下载地址: https://pan.baidu.com/s/1t-8nmTnrpffqRr5Itx8_9g 提取码: s4zh
安装
- 解压压缩包
- 在解压后的文件夹里,打开cmd指令窗口
- 然后输入
redis-server redis.windows.conf
命令
image.png - 部署Redis为windows下的服务,再打开一个新的cmd命令窗口,
输入指令redis-server --service-install redis.windows.conf
image.png -
右键此电脑–>管理–>服务和应用程序–>服务: 启动服务
image.png - 测试Redis,输入
redis-cli.exe
,打开Redis客户端
image.png
如图,是正确的,只是没有权限访问;
输入auth 密码
,进入访问
image.png
基本已经完成了。
密码设置
在配置文件(redis.windows.conf
)设置了密码,密码为123456
################################## SECURITY ###################################
……省略……
# requirepass foobared
requirepass 123456
绑定多个ip地址
################################## NETWORK #####################################
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 192.168.216.130
注意:127.0.0.1
和192.168.216.130
之间通过空格分隔,不是逗号
想让Redis自启动的时候,可以向Windows添加自启动服务
进入到Redis的安装目录,输入redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis
C:\Users\Administrator\Desktop\Redis-x64-3.2.100>redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis
- service-install redis.windows.conf 指定redis配置文件
- loglevel notice 指定日志级别
- service-name Redis 指定服务名称
Redis常用的指令
卸载服务:redis-server --service-uninstall
开启服务:redis-server --service-start
停止服务:redis-server --service-stop
参考:https://www.cnblogs.com/fanshuyao/p/7151601.html?tdsourcetag=s_pctim_aiomsg