Mac 安装 Redis

658 阅读1分钟
# 更新 brew 的镜像地址
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

# 输入之后 cmd 窗的标题会一直闪,持续几分钟直到更新完毕
$ brew update

# 安装
$ brew install redis

# 启动服务的一种方法
$ brew services start redis

# 配置文件位置 /usr/local/etc/redis.conf

# 启动服务并使用配置文件
# 首先进入安装目录
$ cd /usr/local/bin/
# 启动服务,之后会出现一个经典的 redis 图标
$ redis-server /usr/local/etc/redis.conf

# 其实下面命令也能直接启动redis服务
$ redis-server

# 启动 redis 客户端
$ redis-cli
# 代参数的连接
$ redis-cli -h 127.0.0.1 -p 6379 -n 0 -a pwd
# 可以用下面命令查看
$ redis-cli --help