Redis password management
1. How to initialize the redis password?
A total of 2 steps:
A. There is a parameter in the configuration file: requirepass, which is the parameter for configuring the redis access password.
For example, requirepass test123
B. If the parameters in the configuration file take effect, restart redis.
2. How do I configure the password without restarting redis?
A. Configure the requirepass password in the configuration file (the password is still valid when redis is restarted ).
# Requirepass foobared
If changed:
Requirepass test123
B. Enter redis redefinition Parameters
View the current password:
[Root @ slaver251 redis-2.4.16] #./src/redis-cli-p 6379
Redis 127.0.0.1: 6379>
Redis 127.0.0.1: 6379> config get requirepass
1) "requirepass"
2) (nil)
Show that the password is empty,
Then set the password:
Redis 127.0.0.1: 6379> config set requirepass test123
OK
Query the password again:
Redis 127.0.0.1: 6379> config get requirepass
(Error) ERR operation not permitted
An error is reported!
Now you only need password authentication.
Redis 127.0.0.1: 6379> auth test123
OK
Query the password again:
Redis 127.0.0.1: 6379> config get requirepass
1) "requirepass"
2) "test123"
The password has been modified.
When redis can be restarted, the password will automatically take effect because the configuration parameters have been modified.
If no password is added to the configuration parameter, the password for redis restart is equivalent to not set.
3. How do I log on to redis with a password?
A. Enter the password when logging on.
[Root @ slaver251 redis-2.4.16] #./src/redis-cli-p 6379-a test123
Redis 127.0.0.1: 6379>
Redis 127.0.0.1: 6379> config get requirepass
1) "requirepass"
2) "test123"
B. log on first and then verify:
[Root @ slaver251 redis-2.4.16] #./src/redis-cli-p 6379
Redis 127.0.0.1: 6379>
Redis 127.0.0.1: 6379> auth test123
OK
Redis 127.0.0.1: 6379> config get requirepass
1) "requirepass"
2) "test123"
Redis 127.0.0.1: 6379>
4. The master has a password. How can I configure slave?
When the master node has a password and slave is configured, the corresponding Password parameters must be configured accordingly. Otherwise, slave cannot be copied normally.
The corresponding parameters are:
# Masterauth
For example:
Masterauth mstpassword
Install and test Redis in Ubuntu 14.04
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Redis. conf
Redis details: click here
Redis: click here
This article permanently updates the link address: