English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Redis Security

We can set the password parameter in the redis configuration file, so that the client needs to authenticate the password when connecting to the redis service, which can make your redis service more secure.

Online Examples

We can check if password verification is set with the following command:

127.0.0.1:6379>  CONFIG  get  requirepass
1)  "requirepass"
2)  ""

By default, the requirepass parameter is empty, which means you do not need to authenticate with a password to connect to the redis service.

You can modify this parameter with the following command:

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

After setting the password, the client needs to authenticate the password when connecting to the redis service, otherwise the command cannot be executed.

Syntax

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

127.0.0.1:6379>  AUTH  password

Online Examples

127.0.0.1:6379>  AUTH  "w3codebox
OK
127.0.0.1:6379>  SET  mykey  "Test value"
OK
127.0.0.1:6379>  GET  mykey
"Test value"