Redis连接命令

来源:互联网 发布:c语言多进程编程实例 编辑:程序博客网 时间:2024/06/18 13:34

AUTH password(验证密码是否正确):

127.0.0.1:6379> auth "123"(error) ERR Client sent AUTH, but no password is set

查看是否设置了密码验证

127.0.0.1:6379> config get requirepass1) "requirepass"2) ""
默认情况下 requirepass 参数是空的,这就意味着你无需通过密码验证就可以连接到 redis 服务。
设置密码验证:

127.0.0.1:6379> config set requirepass "123"OK
127.0.0.1:6379> auth 222(error) ERR invalid password127.0.0.1:6379> auth "222"(error) ERR invalid password127.0.0.1:6379> auth "123"OK

ECHO message(打印字符串):

127.0.0.1:6379> echo "hahahahah""hahahahah"

PING(查看服务是否运行):

127.0.0.1:6379> pingPONG

QUIT(关闭当前连接):


SELECT index(切换到指定的数据库):

127.0.0.1:6379> select 11OK