Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis password Management-how to initialize the password for redis

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

How to initialize the password for redis? In order to make everyone more redis password management, Xiaobian summed up the following content, let's look down.

one。 How to initialize the password for redis?

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.

Like requirepass test123.

b. Restart redis is required for the parameters in the configuration file to take effect.

Recommended: redis getting started tutorial

two。 How do I configure a password without restarting redis?

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

# requirepass foobared

If it is modified to:

Requirepass test123

b. Enter redis to redefine parameters

View the current password:

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

Show that the password is empty

Then set the password:

Redis 127.0.0.1 6379 > config set requirepass test123OK

Query the password again:

Redis 127.0.0.1 redis 6379 > config get requirepass (error) ERR operation not permitted

I made a mistake at this time!

Now all you need is password authentication.

Redis 127.0.0.1 6379 > auth test123OK

Query the password again:

Redis 127.0.0.1 requirepass 6379 > config get requirepass "requirepass"test123"

The password has been changed.

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

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

three。 How do I log in to redis with a password?

a. Enter the password when you log in.

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

b. Log in before you verify:

[root@slaver251 redis-2.4.16] #. / src/redis-cli-p 6379redis 127.0.0.1 6379redis 6379 > redis 127.0.0.1 6379redis 6379 > auth test123OKredis 127.0.0.1 6379redis 6379 > config get requirepass "requirepass"test123" 6379redis 127.0.0.1

four。 Master has a password, how to configure slave?

When master has a password to configure slave, the corresponding password parameters must also be configured accordingly. Otherwise, slave will not be able to copy normally.

The corresponding parameters are:

# masterauth

For example:

Masterauth mstpassword

After reading the appeal, do you have a general understanding of redis password management-how to initialize redis passwords? If you want to know more, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report