redis配置密码 1.通过配置文件进行配置 yum方式安装的redis配置文件通常在/etc/redis.conf中,打开配置文件找到 #requirepass foobared 去掉行前的注释,并修改密码为所需的密码,保存文件 requirepass myRedis 重启redis sudo service redis restart#或者sudo
redis配置密码#requirepass foobared
requirepass myRedis
sudo service redis restart #或者 sudo service redis stop sudo redis-server /etc/redis.conf
redis-cli -h 127.0.0.1 -p 6379 redis 127.0.0.1:6379> redis 127.0.0.1:6379> keys * (error) ERR operation not permitted redis 127.0.0.1:6379> select 1 (error) ERR operation not permitted redis 127.0.0.1:6379[1]>
redis-cli -h 127.0.0.1 -p 6379 -a myRedis redis 127.0.0.1:6379> keys * 1) "myset" 2) "mysortset" redis 127.0.0.1:6379> select 1 OK redis 127.0.0.1:6379[1]> config get requirepass 1) "requirepass" 2) "myRedis"
2.通过命令行进行配置
redis 127.0.【本文来自鸿网互联 (http://www.68idc.cn)】0.1:6379[1]> config set requirepass my_redis OK redis 127.0.0.1:6379[1]> config get requirepass 1) "requirepass" 2) "my_redis"
redis-cli -h 127.0.0.1 -p 6379 -a myRedis redis 127.0.0.1:6379> config get requirepass (error) ERR operation not permitted
redis-cli -h 127.0.0.1 -p 6379 -a my_redis redis 127.0.0.1:6379> config get requirepass 1) "requirepass" 2) "my_redis
sudo service redis restart Stopping redis-server: [ OK ] Starting redis-server: [ OK ] redis-cli -h 127.0.0.1 -p 6379 -a my_redis redis 127.0.0.1:6379> config get requirepass (error) ERR operation not permitted redis-cli -h 127.0.0.1 -p 6379 -a myRedis redis 127.0.0.1:6379> config get requirepass 1) "requirepass" 2) "myRedis"
redis-cli -h 127.0.0.1 -p 6379 redis 127.0.0.1:6379> config get requirepass (error) ERR operation not permitted redis 127.0.0.1:6379> auth myRedis OK redis 127.0.0.1:6379> config get requirepass 1) "requirepass" 2) "myRedis"
3.master配置了密码,slave如何配置
#masterauth mstpassword