不多说,直接上干货!
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313221456343-1178311557.png)
再删除redis-64.3.0.503.zip
[94000] 13 Mar 22:21:48.115 # Warning: no config file specified, using the default config. In order to specify a config file use D:SoftWareRedis-3.0 edis-server.exe /path/to/redis.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.503 (00000000/0) 64 bit .-`` .-```. ```/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 94000 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [94000] 13 Mar 22:21:48.120 # Server started, Redis version 3.0.503 [94000] 13 Mar 22:21:48.120 * The server is now ready to accept connections on port 6379
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313222356398-1605392865.png)
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313222419751-1660161363.png)
127.0.0.1:6379>
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313222753295-391609360.png)
127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379>
默认安装Redis的密码是为空的。
因为我们的操作系统大部分还是使用的windows,所以在开发的时候,基本上是用windows下的redis。通过启动redis-server.exe来启动。
redis默认是空密码,但是这样在项目上线后是不安全的,容易被入侵,所以要设置密码。
1、打开redis.windows.conf文件,找到# requirepass foobared 这行,在此行下增加一行requirepass 所设置的密码 ,保存。
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313223950624-381103534.png)
· 这个密码123456随大家自定义,我这里设置如下
# requirepass foobared requirepass 123456 //此处注意,行前不能有空格
2、打开cmd(windows命令窗口),切换到redis-server.exe目录下。
3、输入命令:redis-server.exe redis.windows.conf启动redis,即可使用密码了。
Microsoft Windows [版本 10.0.16299.125] (c) 2017 Microsoft Corporation。保留所有权利。 C:Userslenovo>cd /d D: D:>cd D:SoftWareRedis-3.0 D:SoftWareRedis-3.0>redis-server.exe redis.windows.conf _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.503 (00000000/0) 64 bit .-`` .-```. ```/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 57812 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [57812] 13 Mar 22:50:43.330 # Server started, Redis version 3.0.503 [57812] 13 Mar 22:50:43.333 * The server is now ready to accept connections on port 6379
注意,如果不是用命令窗口,而是直接点击redis-server.exe启动redis,密码不会生效,因为此文件默认加载的是内置的配置文件,必须指定我们设置好的配置文件,密码才会生效。
连接redis报此错误:ERR Client sent AUTH, but no password is set
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313225609105-150544354.png)
127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379> auth 123456 (error) ERR Client sent AUTH, but no password is set 127.0.0.1:6379> CONFIG SET requirepass "123456" OK 127.0.0.1:6379> auth 123456 OK 127.0.0.1:6379>
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313225839235-1215975468.png)
![](https://images2018.cnblogs.com/blog/855959/201803/855959-20180313230442962-1376329693.png)
C:Userslenovo>cd /d D: D:>cd D:SoftWareRedis-3.0 D:SoftWareRedis-3.0>redis-server --service-install redis.windows.conf --loglevel verbose [6660] 13 Mar 23:04:16.850 # Granting read/write access to 'NT AUTHORITYNetworkService' on: "D:SoftWareRedis-3.0" "D:SoftWareRedis-3.0" [6660] 13 Mar 23:04:16.850 # Redis successfully installed as a service. D:SoftWareRedis-3.0>
或者,打开cmd窗口输入services.msc,Redis出现在服务中,自行启动该服务。
C:Userslenovo>cd /d D: D:>cd D:SoftWareRedis-3.0 D:SoftWareRedis-3.0> redis-server --service-uninstall
同时,大家可以关注我的个人博客:
http://www.cnblogs.com/zlslch/ 和 http://www.cnblogs.com/lchzls/ http://www.cnblogs.com/sunnyDream/
详情请见:http://www.cnblogs.com/zlslch/p/7473861.html
人生苦短,我愿分享。本公众号将秉持活到老学到老学习无休止的交流分享开源精神,汇聚于互联网和个人学习工作的精华干货知识,一切来于互联网,反馈回互联网。
目前研究领域:大数据、机器学习、深度学习、人工智能、数据挖掘、数据分析。 语言涉及:Java、Scala、Python、Shell、Linux等 。同时还涉及平常所使用的手机、电脑和互联网上的使用技巧、问题和实用软件。 只要你一直关注和呆在群里,每天必须有收获
对应本平台的讨论和答疑QQ群:大数据和人工智能躺过的坑(总群)(161156071)