redis简介:
redis是一个缓存数据库,里面的数据都是字符串,使用key-value形式存储,使用redis缓存数据库可以提高系统的访问性能,一般开发时使用Windows下的redis服务器,生产时使用linux下的服务器。
一、下载Windows版本的redis
下载地址:https://github.com/MicrosoftArchive/redis/releases
二、安装与配置
1、将下载下来的安装包解压到指定文件夹下
3、将redis服务安装到Windows中
执行命令:redis-server --service-install redis.windows-service.conf --loglevel verbose
这是我们可以在Windows的服务列表中看到redis服务。如下:
此时redis的状态还是未启用的状态,我们可以执行命令启动它。
4、启动redis
执行命令:redis-server --service-start
使用F5刷新Windows列表,这时Windows的服务列表中redis变为运行状态,如下:
到这里redis就搭建成功了。
卸载redis的命令:redis-server --service-uninstall
停止redis的命令:redis-server --service-stop
三、测试redis
1、连接redis:redis-cli -h 127.0.0.1 -p 6379
127.0.0.1代表主机,使用localhost也可以,或者直接命令:redis-cli也可以直接连,默认为本地连接,默认端口6379
2、简单测试
在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 logan123
logan123就是密码
################################## 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 root123456
连接redis:redis-cli -h 127.0.0.1 -p 6379 -a root123456
expire用来设置超期时间
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。