我们使用brew命令安装,使用brew之前需要安装Homebrew并换源,可以加快速度
检查可安装版本
使用命令brew search redis
我们可以看到redis的版本
$ brew search redis
==> Formulae
hiredis redis redis-leveldb [email protected] [email protected]
==> Casks
another-redis-desktop-manager redis redisinsight
(base)
安装redis
命令brew install redis
@后面的是版本号,不指定安装最新版本,我这里是6.0.8
$ brew install redis
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/redis-6.0.8.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Pouring redis-6.0.8.catalina.bottle.tar.gz
==> Caveats
To have launchd start redis now and restart at login:
brew services start redis
Or, if you don't want/need a background service you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
/usr/local/Cellar/redis/6.0.8: 13 files, 3.8MB
(base)
安装成功后给了提示信息,
To have launchd start redis now and restart at login:
brew services start redis
这就是启动命令了
启动redis
1.启动redis服务
brew services start redis
2.关闭redis服务
brew services stop redis
3.重启redis服务
brew services restart redis
4.通过bin目录启动
cd /usr/local/Cellar/redis/6.0.8/bin
./redis-server
配置开机启动redis
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
查看 redis 是否启动?
使用命令redis-cli
,进入redis命令窗口,exit退出,6379是redis服务器的端口号,和mysql的3306应该是一个意思
$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> exit
(base)