Home> Database> Redis> body text

Introduction to redis password management

Release: 2020-03-20 09:50:09
forward
1982 people have browsed it

Introduction to redis password management

1. How to initialize the redis password?

A total of 2 steps:

a. There is a parameter in the configuration file: requirepass This is the parameter to configure the redis access password.

For example, requirepass test123

b. To take effect, the parameters in the configuration file need to be restarted and redis restarted.

Recommended:redis introductory tutorial

2. How to configure the password without restarting redis?

a. In the configuration file Configure the password for requirepass (the password is still valid when redis is restarted).

# requirepass foobared
Copy after login

For example, change it to:

requirepass test123
Copy after login

b. Enter the redis redefinition parameter

to view the current password:

[root@slaver251 redis-2.4.16]# ./src/redis-cli -p 6379 redis 127.0.0.1:6379> redis 127.0.0.1:6379> config get requirepass "requirepass" (nil)
Copy after login

shows that the password is empty,

Then set the password:

redis 127.0.0.1:6379> config set requirepass test123 OK
Copy after login

Query the password again:

redis 127.0.0.1:6379> config get requirepass (error) ERR operation not permitted
Copy after login

An error is reported at this time!

Now only password authentication is required.

redis 127.0.0.1:6379> auth test123 OK
Copy after login

Query the password again:

redis 127.0.0.1:6379> config get requirepass "requirepass" "test123"
Copy after login

The password has been changed.

When it is time to restart redis because the configuration parameters have been modified, the password will automatically take effect.

If the configuration parameter does not add a password, then the password for redis restart will be equivalent to no setting.

3. How to log in to redis with a password?

a. When logging in, enter the password

[root@slaver251 redis-2.4.16]# ./src/redis-cli -p 6379 -a test123 redis 127.0.0.1:6379> redis 127.0.0.1:6379> config get requirepass "requirepass" "test123"
Copy after login

b. Log in first and then verify:

[root@slaver251 redis-2.4.16]# ./src/redis-cli -p 6379 redis 127.0.0.1:6379> redis 127.0.0.1:6379> auth test123 OK redis 127.0.0.1:6379> config get requirepass "requirepass" "test123" redis 127.0.0.1:6379>
Copy after login

4. Master has a password, how about slave? Configuration?

When the master has a password, the corresponding password parameters must also be configured accordingly when configuring the slave. Otherwise, the slave cannot perform normal replication.

The corresponding parameters are:

#masterauth
Copy after login

For example:

masterauth mstpassword
Copy after login

Related recommendations:

mysql video tutorial:https:// m.sbmmt.com/course/list/51.html

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

Related labels:
source:csdn.net
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!