Password setting
Here is a brief introduction to how to set a password for redis (recommended: redis introductory tutorial)
There are two ways to set the redis password, one requires restarting the redis service, and the other does not require restarting the redis service.
First of all, let’s introduce the setting method that needs to restart the redis service.
That is, find the redis configuration file—redis.conf file, and then modify the requirepass inside. This was originally commented out. Remove the comments, set the corresponding fields behind to the password you want, save and exit. Just restart the redis service.
I set the password here to 123
Then there is a password setting method that does not require restarting the redis service
This is relatively simple , after connecting to redis, set it through the command, as follows:
config set requirepass 123456
In this way, the password is set to 123456
After setting, you can check the password through the following command
config get requirepass
After the password is set, when you log out and connect to redis again, you need to enter the password, otherwise it will not work. There are two ways to enter the password. One is to enter the password directly when connecting, but to enter the password after connecting, as shown below:
In fact, there is a small problem, that is, through After the password is changed on the command line, the password after the requirepass field in the configuration file will not be changed accordingly.
The above is the detailed content of Detailed explanation of how to set password in redis. For more information, please follow other related articles on the PHP Chinese website!