1.Redis登录
不需要密码时
bogon:~ wangjianwen$ redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
需要密码时 -a 后输入的即为redis密码;远程登录redis也是下边的方式。
[root@bogon ~]# redis-cli -h 127.0.0.1 -p 6379 -a "123456"
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> PING
PONG
验证方式: PING一下,如果返回PONG说明登录成功。默认是登录的0库。
2.选择并删除指定库数据
slecect dbid:dbid即为redis某一个子库的id,redis默认最多是16个子库,编号从0-15.dbsize:查询对应子库key的个数。flushdb:删除当前库key
127.0.0.1:6379> select 3 // 选择3库
OK
127.0.0.1:6379[3]> dbsize // 查询3库key个数,结果为7个
(integer) 7
127.0.0.1:6379[3]> flushdb // 删除3库全部key
OK
127.0.0.1:6379[3]> dbsize // 删除后key为0
(integer) 0
3. 删除全部数据
flushall:删除全部数据
参考:Redis教程