Home > Database > Redis > body text

How to set a password for Redis

青灯夜游
Release: 2019-06-17 16:05:27
Original
58711 people have browsed it

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. The following article will introduce these two methods to you, I hope it will be helpful to you.

How to set a password for Redis

Method 1: Set through the configuration file (/etc/redis.conf)

In this method, after setting the password You need to restart redis to take effect. First find the redis configuration file—redis.conf file, and then modify the requirepass inside (requirepass is the parameter for configuring the redis access password). This is originally commented out. Remove the comment and set the corresponding fields to what you want. Password required, save and exit. Just restart the redis service. (Recommended learning: Redis video tutorial)

How to set a password for Redis

I set the password here to 123

Method 2: Pass Command to set password

This method is relatively simple and does not require restarting the redis service. 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 a password for Redis

After setting the password, when you exit 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 a password for Redis

Note: Through the command After you change the password, the password behind the requirepass field in the configuration file (/etc/redis.conf) will not be changed accordingly.

For more redis related technical knowledge, please visit the Redis usage tutorial column to learn!

The above is the detailed content of How to set a 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