Easy Tutorial
❮ Scripting Script Kill Server Time ❯

Redis Security

We can set a password parameter through Redis's configuration file, so that clients need to authenticate with a password when connecting to the Redis service, making your Redis service more secure.

Example

We can check if a password is set using the following command:

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 with the following command:

127.0.0.1:6379> CONFIG set requirepass "tutorialpro"
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "tutorialpro"

After setting the password, clients need to authenticate with the password to connect to the Redis service, otherwise they cannot execute commands.

Syntax

The basic syntax for the AUTH command is as follows:

127.0.0.1:6379> AUTH password

Example

127.0.0.1:6379> AUTH "tutorialpro"
OK
127.0.0.1:6379> SET mykey "Test value"
OK
127.0.0.1:6379> GET mykey
"Test value"
❮ Scripting Script Kill Server Time ❯