近期打算把开发环境由Widows换到Mac OS X,而Mac OS X有点另类,很多软件的安装方法也与众不同,因此也顺便写点心得体会把,今天简单介绍一下Redis在Mac OS X下的安装以及使用方法。
首先从Redis官网http://www.redis.io去下载最新版本的Redis安装文件(此处以Redis版本为例进行说明)。
Redis 2.6.16版本的下载地址:http://download.redis.io/releases/redis-2.6.16.tar.gz
下载后进行解压缩。
然后在提示符处输入:$make
即可完成Redis安装。
若此处提示make命令不存在,请参考这篇《Mac下没有make命令解决办法》博文教的方法,安装xcode以及Command Line Tools,就可以使用make命令了。
安装完Redis后,在终端中输入:
1 |
即可启动Redis服务。
要关闭Redis服务也很简单,先用Redis客户端连上Redis服务,用SHUTDOWN命令即可关闭服务。
进入服务器命令行
1 |
$src/redis-cli |
关闭服务器
redis 127.0.0.1:6379> SHUTDOWN
其他Redis的命令,大家可以访问Redis官网进行查阅,该作者对每一条命令都做了详细解说,这里就不累赘说明了。
1 2 3 4 5 6 7 8 |
#平时启动报错,则 执行下面的命令 Could not connect to Redis at 127.0.0.1:6379: Connection refused redis-server /usr/local/etc/redis.conf #启动redis #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 |
type below:
1 2 |
brew update brew install redis |
To have launchd start redis now and restart at login:
1 |
brew services start redis |
to stop it, just run:
1 |
brew services stop redis |
Or, if you don't want/need a background service you can just run:
1 |
redis-server /usr/local/etc/redis.conf |
Test if Redis server is running.
1 |
redis-cli ping |
If it replies “PONG”, then it’s good to go!
Location of Redis configuration file.
1 |
/usr/local/etc/redis.conf |
Uninstall Redis and its files.
1 2 |
brew uninstall redis rm ~/Library/LaunchAgents/homebrew.mxcl.redis.plist |
M1 芯片 Mac 安装 Redis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
❯ brew install redis Running `brew update --auto-update`... fatal: It seems that there is already a rebase-merge directory, and I wonder if you are in the middle of another rebase. If that is the case, please try git rebase (--continue | --abort | --skip) If that is not the case, please rm -fr ".git/rebase-merge" and run me again. I am stopping in case you still have something valuable there. ==> Downloading https://ghcr.io/v2/homebrew/core/redis/manifests/7.0.0 ######################################################################## 100.0% ==> Downloading https://ghcr.io/v2/homebrew/core/redis/blobs/sha256:79e59848cb1afb3107612980c29c85d321e8abec2779 ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:79e59848cb1afb3107612980c29 ######################################################################## 100.0% ==> Pouring redis--7.0.0.arm64_monterey.bottle.tar.gz ==> Caveats To restart redis after an upgrade: brew services restart redis Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf ==> Summary 🍺 /opt/homebrew/Cellar/redis/7.0.0: 14 files, 2.6MB ==> Running `brew cleanup redis`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). |
修改密码
1 2 |
vim /opt/homebrew/etc/redis.conf requirepass xxxx |
