跳到主要内容

Mac 上安装使用Redis

安装

brew update
brew install redis

启动和停止

  • 使用 brew services 启动和停止
# 启动
~ brew services start redis
# 查看状态
~ brew services list
Name Status User File
redis started ssgeek ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
# 停止
~ brew services stop redis
  • 使用 redis-server 启动,使用配置文件前台启动
# 启动
~ redis-server /usr/local/etc/redis.conf
# 停止,ctrl+c即可

使用

# 连接到 Redis 服务器
~ redis-cli ping
PONG
~ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set key value
OK

卸载

brew uninstall redis
rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist