CONFIG 命令:
winner@winnerdeMacBook-Pro:~$ Redis-cli127.0.0.1:6379> CONFIG get requirepass1) "requirepass"2) "" --默认没有密码127.0.0.1:6379> CONFIG set requirepass"chenlongfei" --设置密码OK127.0.0.1:6379> QUIT --退出重新连接winner@winnerdeMacBook-Pro:~$ Redis-cli127.0.0.1:6379> SET name "clf"(error) NOAUTH Authentication required. –提示没权限127.0.0.1:6379> AUTH chenlongfei --验证密码OK127.0.0.1:6379> SET name "clf" --之后才能进行操作OK127.0.0.1:6379> GET name"clf"
127.0.0.1:6379> config set save "" --设置不后台save
只支持keys* 通配版本
#!/bin/bashredis_comm=/usr/local/redis-5.0.3/bin/redis-cliredis_ser01=192.168.50.175redis_ser02=192.168.50.174$redis_comm -c -h $redis_ser01 -p 7001 -a xxx keys $1 | xargs -i $redis_comm -c -h $redis_ser01 -p 7001 -a xxx del {}$redis_comm -c -h $redis_ser02 -p 7001 -a xxx keys $1 | xargs -i $redis_comm -c -h $redis_ser02 -p 7001 -a xxx del {}
运行:
./redis_del_key.sh 匹配的key*