设置密码 / 模糊查询
最后更新于:2022-04-02 04:00:38
[TOC]
## 设置密码
### 查看是否设置密码
```
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "" //密码为空
```
### 设置密码
```
127.0.0.1:6379> CONFIG set requirepass "runoob"
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "runoob"
```
### 连接
```
127.0.0.1:6379> AUTH "runoob"
OK
```
## 模糊查询
```
redis 127.0.0.1:6379> flushdb
OK
redis 127.0.0.1:6379> keys *
(empty list or set)
redis 127.0.0.1:6379> mset one 1 two 2 three 3 four 4
OK
redis 127.0.0.1:6379> keys o*
1) "one"
redis 127.0.0.1:6379> key *o
(error) ERR unknown command 'key'
redis 127.0.0.1:6379> keys *o
1) "two"
redis 127.0.0.1:6379> keys ???
1) "one"
2) "two"
redis 127.0.0.1:6379> keys on?
1) "one"
redis 127.0.0.1:6379> set ons yes
OK
redis 127.0.0.1:6379> keys on[eaw]
"one"
```
';