windows 安装 Redis
本文安装的是 免安装版本:
1:
https://github.com/MicrosoftArchive/redis/releases
设置密码
redis.windows.conf:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ################################## 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 123456 这就是密码 |
解压到你的目录下;
2:
1 | D:\soft\Redis>redis-server.exe redis.windows.conf |
3:
再新打开一个cmd(不要关闭之前打的Cmd窗口),启动Redis客户端:
1 | D:\soft\Redis>redis-cli.exe |
4 :获取Redis中某个key的值,提示无权限。
1 2 3 | 127.0.0.1:6379> get name (error) NOAUTH Authentication required. 127.0.0.1:6379> |
5:
通过密码进入访问,使用 auth + 密码,如下:
1 2 3 4 5 6 7 | 127.0.0.1:6379> get name (error) NOAUTH Authentication required. 127.0.0.1:6379> auth 123456 OK 127.0.0.1:6379> get name "ok" 127.0.0.1:6379> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 6、Spring整合Redis的一些配置(JedisPool单机版): Spring.xml文件配置的JedisPool池: Java代码 收藏代码 <bean id= "jedisPool" class = "redis.clients.jedis.JedisPool" > <constructor-arg name= "poolConfig" ref = "jedisPoolConfig" ></constructor-arg> <constructor-arg name= "host" value= "${redis.host}" /> <constructor-arg name= "port" value= "${redis.port}" type= "int" /> <constructor-arg name= "timeout" value= "${redis.timeout}" type= "int" /> <constructor-arg name= "password" value= "#{'${redis.password}'!=''?'${redis.password}':null}" /> <!-- <constructor-arg name= "database" value= "${redis.db.index}" type= "int" /> --> </bean> redis.properties配置文件 Java代码 收藏代码 #*****************jedis连接参数设置*********************# #redis服务器ip# redis.host=192.168.100.66 #redis服务器端口号# redis.port=6379 #超时时间:单位ms# redis.timeout=3000 #授权密码,没有密码则不设置,但属性要保留# redis.password=123456 7、如果不是安装版的Redis,又想让Redis自启动的时候,可以向Windows添加自启动服务: 1、进入到Redis的安装目录 D:\soft\Redis> 2、执行命令: redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis 3、完整示例: D:\soft\Redis>redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis --service-install redis.windows.conf 指定redis配置文件 --loglevel notice 指定日志级别 --service-name Redis 指定服务名称 运行结果如下( Redis successfully installed as a service.): D:\soft\Redis>redis-server --service-install redis.windows.conf --loglevel notice --service-name Redis [7176] 12 Jul 09:34:50.730 # Granting read/write access to 'NT AUTHORITY\NetworkService' on : "D:\soft\Redis" "D:\soft\Redis\" [7176] 12 Jul 09:34:50.730 # Redis successfully installed as a service. 4、安装服务后,默认不是马上启动的,但启动类型是自启动,如果想马上启动,请执行命令:<br> redis-server --service-start 服务成功启动显示如下: [9876] 12 Jul 09:57:41.251 # Redis service successfully started. 或者重启电脑。 停止服务: redis-server --service-stop 5、删除Redis服务: redis-server --service-uninstall |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了