Redis-Password
Redis有以下两个密码设置
- requirepass: 用于客户端连接Redis
- masterauth: 当 Redis Master 节点设置了 requirepass, 需要在 Slave 节点添加配置以连接。
Redis 密码设置可以通过修改配置文件和命令行的方式。注意:命令行的参数配置会在节点重启后消失。
Redis password introduction
requirepass : Guard redis
1 | # Require clients to issue AUTH <PASSWORD> before processing any other |
Master Auth: Replica used to connect master node
1 | # If the master is password protected (using the "requirepass" configuration |
Two ways to set redis password
Set redis password by commands
Note: If we set the password by command(not all configurations support this way) without make config changes persistence. These configurations will disappear after redis restart.
./redis-cli -p -h config set masterauth ‘‘
./redis-cli -p -h config set requirepass ‘‘
Set redis password via configuration file
1 | # requirepass foobared |