- 查看端口号命令
[root@iZm5ee9mxelwecp6gnpr8qZ ~]# ps -ef | grep redis
root 11066 10986 0 15:03 pts/5 00:00:00 grep --color=auto redis
root 24074 1 0 Aug05 ? 02:18:10 ./redis-server *:7479
- 根据端口看查看路径
[root@iZm5ee9mxelwecp6gnpr8qZ ~]# ls -l /proc/24074/cwd
lrwxrwxrwx 1 root root 0 Aug 5 17:00 /proc/24074/cwd -> /usr/local/redis/bin
- 查看路径地址详情
[root@iZm5ee9mxelwecp6gnpr8qZ ~]# cd /usr/local/redis/bin/
[root@iZm5ee9mxelwecp6gnpr8qZ bin]# ls
dump.rdb redis-check-aof redis-cli redis-server
redis-benchmark redis-check-rdb redis-sentinel
- 登陆redis
[root@iZm5ee9mxelwecp6gnpr8qZ bin]# ./redis-cli -h 127.0.0.1 -p 7479
127.0.0.1:6379>
- 登陆redis,进行密码授权
127.0.0.1:6379> auth "yourpassword"
- 查看所有key
127.0.0.1:6379> keys *
- 模糊查看某个key
127.0.0.1:6379> keys hib:socket:union:doctor_*
- 查看key值类型
127.0.0.1:7479> type hib:socket:union:doctor_351
hash
- 获取指定键所有的属性「hkeys」
127.0.0.1:7479> hkeys hib:socket:union:doctor_351
1) "name"
2) "age"
- 获取某个键的某个属性的值(键属性值)「hget」
127.0.0.1:7479> hget hib:socket:union:doctor_351 name
"yuance"
- 获取某个键的多个属性的值「hmget」
127.0.0.1:7479> hmget hib:socket:union:doctor_351 name age
1) "yuance"
2) "18"
- 获取某个键的所有属性的值「hvals」
127.0.0.1:7479> hvals hib:socket:union:doctor_351
1) "yuance"
2) "18"
- 使用 del 命令删除整个 hash 键和属性值
127.0.0.1:7479> del hib:socket:union:doctor_351
(integer) 1
- 使用 hdel 命令删除指定 hash 键的某个属性值,可以同时删除一个或多个属性。
127.0.0.1:7479> del hib:socket:union:doctor_351 name age
(integer) 1