Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Security

Redis Security

We can set the password parameter via Redis's configuration file, so that clients connecting to the redis service require password authentication, making your redis service more secure.

Example

We can use the following command to check whether password authentication is set:



127.0.0.1:6379> CONFIG get requirepass

1) "requirepass"

2) ""

By default, the requirepass parameter is empty, which means you can connect to the redis service without password authentication.

You can modify this parameter via the following command:



127.0.0.1:6379> CONFIG set requirepass "runoob"

OK

127.0.0.1:6379> CONFIG get requirepass

1) "requirepass"

2) "runoob"

After setting a password, clients connecting to the redis service require password authentication; otherwise commands cannot be executed.

Syntax

AUTH The basic syntax format of the command is as follows:



127.0.0.1:6379> AUTH password

Example



127.0.0.1:6379> AUTH "runoob"

OK

127.0.0.1:6379> SET mykey "Test value"

OK

127.0.0.1:6379> GET mykey

"Test value"