参考:http://blog.csdn.net/xiangwanpeng/article/details/54586087
1.在下载目录下
1 | sudo wget http://download.redis.io/releases/redis-3.2.6.tar.gz |
2.解压,并复制到/usr/local目录下
1 | tar -zxvf redis-3.2.6.tar.gz |
3.编译和安装
1 | cd /redis |
4.在redis安装文件夹中修改文件redis.conf,使得redis在后台运行
1 | vim redis.conf |
5.启动redis
1 | redis-server redis.conf |
6.安装redis desktop manager
按照 http://blog.csdn.net/u013410747/article/details/51706964 的步骤
安装deb安装包,需要依赖libicu52
在/etc/apt/目录
下,先拷贝一份cp sources.list sources.list1
然后使用网易的源
1 | deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiversedeb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse |
更新源
1 | sudo apt-get update |
1 | sudo apt-get -f install libicu52 |
最后安装 redis-desktop-manager_0.8.3-120_amd64.deb
给redis设置密码,需要在redis.conf的配置文件中添加
1 | requirepass xxxx |
否则会报没有权限
1 | (error) NOAUTH Authentication required |
需要添加密码参数
1 | redis-cli -p 6379 -a xxxx |
redis默认的databases有16个,可以在配置文件中配置
1 | databases 16 |
使用select来选择当前的库
1 | 127.0.0.1:6379> select 1 |
可以使用 keys *来查看redis中的数据,不过由于redis是单线程的,所以禁止在生产环境中使用keys命令
1 | keys * |
可以使用scan命令来替代keys命令
1 | scan 0 match user* count 10 |
查看key的数据类型,不同的key所对应的命令不一样,否则会报 (error) WRONGTYPE Operation against a key holding the wrong kind of value
1 | type XXXXX |
zset的zcan命令,ZSCAN key cursor [MATCH pattern] [COUNT count]
1 | https://www.runoob.com/redis/sorted-sets-zscan.html |
比如
1 | ZSCAN XXXX 0 |