I. how to initialize the Redis password.
A total of 2 steps:
A. There is a parameter in the configuration file: Requirepass This is the parameter that configures the Redis access password.
Like Requirepass test123.
B. The parameters in the configuration file need to be restarted to restart Redis.
Ii. do not restart Redis How do I configure a password?
A. Configure the Requirepass password in the configuration file (the password is still valid when Redis restarts).
# Requirepass Foobared
As modified to:
Requirepass test123
B. Enter Redis redefine parameters
To 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)
The display password is empty,
Then set the password:
Redis 127.0.0.1:6379> Config set Requirepass test123
Ok
Check password again:
Redis 127.0.0.1:6379> config Get requirepass
(Error) ERR Operation not permitted
This is an error.
Now you just need the password authentication.
Redis 127.0.0.1:6379> Auth test123
Ok
Check password again:
Redis 127.0.0.1:6379> config Get requirepass
1) "Requirepass"
2) "Test123"
The password has been modified.
When the Redis is ready to restart, the password will automatically take effect because the configuration parameters have been modified.
If the configuration parameter does not add a password then the Redis restart password will be equivalent to no settings.
Three. how to log in with a password for Redis.
A. Enter the password when you log in
[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 in again to 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>
Four. Master has a password and slave how to configure it.
When Master has a password, the corresponding password parameters should be configured appropriately when the slave is configured. Otherwise, slave is not able to replicate normally.
The corresponding parameters are:
#masterauth
Like what:
Masterauth Mstpassword
Original address: http://blog.csdn.net/lxpbs8851/article/details/8136126