mac系统下Redis安装和使用
一、redis 安装 和启动
用brew安装
1.查看系统是否已经安装了Redis
brew info redis
这个命令会展示此系统下的redis信息,如果没有安装,会展示not install
2.输入命令安装Redis
brew install redis
可能需要等一会,系统下载完redis的包,会自动进行安装
3.启动redis
brew services start redis
这个命令会在后台启动redis服务,并且每一次登录系统,都会自动重启
4.假如你不需要后台启动服务,你可以使用配置文件启动:
redis-server /usr/local/etc/redis.conf
这个命令会读取redis的配置文件,并且在redis运行的过程中也会看到实时的日志打印。启动成功,如下所示:
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 52462
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
5.连接redis
需要新打开一个终端,再输入如下的命令:
# 不需要身份认证时
redis-cli -p 6379 -h 127.0.0.1
# 需要身份认证时,输入如下命令
redis-cli -p 6379 -h 127.0.0.1 -a yourpassword
# or
redis-cli -p 6379 -h 127.0.0.1
# 登录进去之后再进行身份认证
127.0.0.1:6379> auth 0903
官网下载安装包进行安装
下载稳定版安装包:redis官网下载,选择Stable版本进行安装Latest Stable
下载完成后进入到安装包的目录,依次输入如下的命令:
# 移动
sudo mv redis-stable.tar.gz /usr/local
# 切换到目录
cd /usr/local
# 解压
sudo tar zxvf redis-stable.tar.gz
# 切换到redis-stable目录
cd redis-stable
# 编译测试
sudo make test
# 编译安装
sudo make install
执行sudo make install,看到下面结果安装成功:
(base) cuixin@cuixindeMacBook-Pro redis-stable % sudo make install
cd src && /Applications/Xcode.app/Contents/Developer/usr/bin/make install
/bin/sh: pkg-config: command not found
CC Makefile.dep
/bin/sh: pkg-config: command not found
INSTALL redis-sentinel
INSTALL redis-check-rdb
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
redis的启动和停止
启动redis:redis-server
(base) cuixin@cuixindeMacBook-Pro etc % redis-server
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 7.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 52462
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
52462:M 26 Oct 2022 14:35:16.935 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
52462:M 26 Oct 2022 14:35:16.935 # Server initialized
52462:M 26 Oct 2022 14:35:16.936 * Ready to accept connections
链接redis:
(base) cuixin@cuixindeMacBook-Pro redis-stable % redis-cli -p 6379 -h 127.0.0.1
127.0.0.1:6379> set name 'james'
OK
127.0.0.1:6379> get name
"james"
127.0.0.1:6379>
参考链接:mac安装redis教程
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhfhfjkc
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
怎样阻止微信小程序自动打开
PHP中文网 06-13