An example of Redis setting password protection


When Redis is installed, it is not password protected by default, and password protected for security purposes.

 Log in locally on the client side 192.168.56.56 The server
[root@shanxi src]# ./redis-cli

 View password. The current password is empty
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""

 Set the password to  aabbcc
127.0.0.1:6379> config set requirepass "aabbcc"
OK

 Check the password again, it shows insufficient permissions, need to log in again
127.0.0.1:6379> config get requirepass
(error) NOAUTH Authentication required.

127.0.0.1:6379> exit

 Log back in
[root@shanxi src]# ./redis-cli

 Verify password is  aabbcc
127.0.0.1:6379> auth "aabbcc"
OK

 Check the password again   Is shown as  aabbcc  Yes, it worked
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "aabbcc"