连接
redis-cli -h ip -p port -a password
[user@test ~]$ redis-cli -h 192.*.*.* -p 6379 -a '******'
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.*.*.*:6379>
默认选择db0
若需要切换db,use ‘select dbNum’
192.*.*.*:6379> SELECT 1
OK
查看所有的key
192.*.*.*:6379[1]> keys *
1) "key1"
2) "key2"
3) "key3"
查看key的存储类型
192.*.*.*:6379[1]> type 'stock_data'
list
查看list型的大小
192.*.*.*:6379[1]> llen 'key1'
(integer) 47410
判断某个Key是否存在
192.*.*.*:6379[1]> exists 'key1'
(integer) 1
删除某个key值
192.*.*.*:6379[1]> del 'key1'
(integer) 1
为key取新的名字
192.*.*.*:6379[1]> rename 'key1' 'key2'
OK
本文详细介绍了如何使用redis-cli连接Redis服务器,包括设置密码、选择数据库、查看和管理键值对等基本操作,是Redis初学者和日常使用者的实用参考。

被折叠的 条评论
为什么被折叠?



