Redis command o...login
Redis command operation Chinese manual
author:php.cn  update time:2022-04-12 14:07:28

Redis security


Redis Security

We can set the password parameter through the redis configuration file, so that the client needs password verification to connect to the redis service, which can make your redis service more secure.

Example

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

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 pass password verification. You can connect to the redis service.

You can modify this parameter through the following command:

127.0.0.1:6379> CONFIG set requirepass "w3cschool.cc"
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "w3cschool.cc"

After setting the password, the client needs password verification to connect 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

Example

127.0.0.1:6379> AUTH "w3cschool.cc"
OK
127.0.0.1:6379> SET mykey "Test value"
OK
127.0.0.1:6379> GET mykey
"Test value"

php.cn