mac os 安装 redis
使用Homebrew安装Redis
1、没有安装Homebrew,首先安装homebrew
2、使用Homebrew安装命令
brew install redis
出现类似如下的信息即为安装成功
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/redis-6.0.1 ######################################################################## 100.0% ==> Pouring redis-6.0.1.mojave.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.1: 13 files, 3.7MB
3、安装位置
1 Homebrew安装的软件会默认在/usr/local/Cellar/路径下;
2 redis的配置文件redis.conf存放在/usr/local/etc路径下
4、启动
1 cd /usr/local/redis/bin 2 redis-server

5、查看redis服务进程
ps -ef | grep redis
看到redis-server进程则成功。

6、redis-cli连接redis服务
redis默认端口号6379,默认auth为空,输入以下命令即可连接
redis-cli -h 127.0.0.1 -p 6379
7、启动 redis 客户端,打开终端并输入命令 redis-cli。该命令会连接本地的 redis 服务。
$redis-cli redis 127.0.0.1:6379> redis 127.0.0.1:6379> PING PONG
在以上实例中我们连接到本地的 redis 服务并执行 PING 命令,该命令用于检测 redis 服务是否启动。
8、关闭redis服务
正确停止Redis的方式应该是向Redis发送SHUTDOWN命令
redis-cli shutdown
强行终止redis
sudo pkill redis-server

浙公网安备 33010602011771号