mac下需要有homebrew
brew search redis查看是否有redis,有的话就可以安装了,如下
brew install redis
==> Downloading https://homebrew.bintray.com/bottles/redis-3.0.5.yosemite.bottle
######################################################################## 100.0%
==> Pouring redis-3.0.5.yosemite.bottle.tar.gz
==> Caveats
To have launchd start redis at login:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
/usr/local/Cellar/redis/3.0.5: 9 files, 892K
安装好之后
启动redis
➜ ~ redis-server
3599:C 19 Nov 16:18:05.832 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
3599:M 19 Nov 16:18:05.834 * Increased maximum number of open files to 10032 (it was originally set to 2560).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.5 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 3599
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
3599:M 19 Nov 16:18:05.839 # Server started, Redis version 3.0.5
3599:M 19 Nov 16:18:05.840 * The server is now ready to accept connections on port 6379
============
新打开一个iTerm
➜ ~ redis-cli
查看所有的key
127.0.0.1:6379> keys '**'
(empty list or set)
给数据库中名称为key的string赋予值value
127.0.0.1:6379> set name yihua
OK
返回数据库中名称为key的string的value
127.0.0.1:6379> get name
"yihua"
127.0.0.1:6379>
最简单的安装,一切都是默认的,实际需要还得使用另一配置文件
关闭redis
redis-cli shutdown