Home > Database > Redis > How to set password for redis

How to set password for redis

藏色散人
Release: 2019-08-01 15:44:29
Original
31113 people have browsed it

How to set password for redis

#How to set a password for redis?

Password setting

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.

How to set password for redis

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
Copy after login

In this way, the password is set to 123456

After setting, you can check the password through the following command

config get requirepass
Copy after login

How to set password for redis

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 follows:

How to set password for redis

In fact, there is another A small problem is that after changing the password through the command line, the password behind the requirepass field in the configuration file will not be changed accordingly.

For more Redis related knowledge, please visit the Redis usage tutorial column!

The above is the detailed content of How to set password for redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template