redis下载及安装教程

一、Redis 简介

Redis 是一个开源的高性能 Key-Value 数据库,常用于缓存、消息队列、会话管理等场景。

它支持多种数据结构(String、Hash、List、Set、Sorted Set 等),单线程事件驱动,性能非常高。


二、安装方式总览

系统 推荐方式
Windows 下载微软维护的 Redis for Windows 版本(或 WSL 安装)
Linux 用包管理器(yum/apt)或源码编译
macOS 用 Homebrew 安装

三、各平台安装步骤

1. Windows 安装

官方 Redis 不再原生支持 Windows,建议用微软维护的移植版或 WSL。

方法 A:使用 Redis for Windows(社区移植版)

  1. 进入 GitHub 下载地址(microsoft archive 版):
    github.com/microsoftar...
  2. 找到最新的 .zip 压缩包,例如:
    Redis-x64-3.2.100.zip
  3. 解压到一个目录,例如 C:\Redis
  4. 打开 PowerShell,进入目录:cd C:\Redis redis-server.exe redis.windows.conf
  5. 再开一个 PowerShell 连接客户端:redis-cli.exe 输入:set name "hello" get name

方法 B:WSL 安装(推荐)

  1. 在 Windows 10/11 开启 Windows Subsystem for Linux
  2. 安装 Ubuntu 子系统:wsl --install -d Ubuntu
  3. 在 Ubuntu 里安装 Redis:sudo apt update sudo apt install redis-server sudo service redis-server start redis-cli

2. Linux 安装

方法 A:APT(Debian/Ubuntu)

vbscript 复制代码
sudo apt update
sudo apt install redis-server
sudo systemctl enable redis-server
sudo systemctl start redis-server
php
114 Bytes
© 菜鸟-创作你的创作

方法 B:YUM(CentOS/RHEL)

sql 复制代码
sudo yum install epel-release
sudo yum install redis
sudo systemctl enable redis
sudo systemctl start redis
php
107 Bytes
© 菜鸟-创作你的创作

方法 C:源码编译(通用)

go 复制代码
wget http://download.redis.io/releases/redis-7.2.4.tar.gz
tar -zxvf redis-7.2.4.tar.gz
cd redis-7.2.4
make
sudo make install
redis-server
php
137 Bytes
© 菜鸟-创作你的创作

3. macOS 安装

使用 Homebrew

sql 复制代码
brew update
brew install redis
brew services start redis
redis-cli
php
66 Bytes
© 菜鸟-创作你的创作

四、启动与测试

启动 Redis

vbscript 复制代码
redis-server
php
12 Bytes
© 菜鸟-创作你的创作

客户端连接

sql 复制代码
redis-cli
set user "xiaoming"
get user
php
38 Bytes
© 菜鸟-创作你的创作

检查是否运行

bash 复制代码
redis-cli ping
# 返回 PONG 表示正常
php
29 Bytes
© 菜鸟-创作你的创作

五、常用配置文件位置

  • Linux/etc/redis/redis.conf
  • macOS (brew)/usr/local/etc/redis.conf
  • Windows 移植版redis.windows.conf

建议常改的配置:

bash 复制代码
bind 0.0.0.0        # 允许远程访问
requirepass 123456  # 设置密码
php
55 Bytes
© 菜鸟-创作你的创作

修改后重启:

复制代码
sudo systemctl restart redis
php
28 Bytes
© 菜鸟-创作你的创作

www.52runoob.com/archives/55...

相关推荐
一 乐15 分钟前
酒店客房预订|基于springboot + vue酒店客房预订系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端
计算机毕设指导616 分钟前
基于Spring Boot的防诈骗管理系统【源码文末联系】
java·spring boot·后端·spring·tomcat·maven·intellij-idea
开心就好202521 分钟前
IOScer 开发环境证书包括哪些,证书、描述文件与 App ID 的协同管理实践
后端
码事漫谈31 分钟前
终于找到我想要的远程工具了!
后端
我家领养了个白胖胖31 分钟前
MCP模型上下文协议 Model Context Protocol & 百度地图MCP开发
java·后端·ai编程
Coder_Boy_33 分钟前
基于DDD+Spring Boot 3.2+LangChain4j构建企业级智能客服系统
java·人工智能·spring boot·后端
开心猴爷35 分钟前
苹果商店 App 上架要求,探讨如何通过系统审核
后端
开心就好202535 分钟前
Flutter 应用加固在真实项目中的实践方式,当 Dart 之外还有一整个 IPA
后端
黄俊懿40 分钟前
【深入理解SpringCloud微服务】Spring-Security作用与原理解析
java·后端·安全·spring·spring cloud·微服务·架构师
我是谁的程序员42 分钟前
iOS 开发中证书创建与管理中的常见问题
后端