In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to configure authentication password in Redis". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure the authentication password for Redis.
Redis configuration password
1. Configure through a configuration file
The redis configuration file installed in yum is usually in / etc/redis.conf. Open the configuration file and find it.
# requirepass foobared
Remove the comments before the line, change the password to the required password, and save the file
Requirepass myRedis
Restart redis
Sudo service redis restart
# or
Sudo service redis stop
Sudo redis-server / etc/redis.conf
At this time, I tried to log in to redis and found that I could log in, but the specific command was prompted that the operation was not allowed.
Redis-cli-h 127.0.0.1-p 6379
Redis 127.0.0.1 purl 6379 >
Redis 127.0.0.1 6379 > keys *
(error) ERR operation not permitted
Redis 127.0.0.1 6379 > select 1
(error) ERR operation not permitted
Redis 127.0.0.1 6379 [1] >
Try to log in with a password and execute the specific command to see that it can be executed successfully
Redis-cli-h 127.0.0.1-p 6379-a myRedis
Redis 127.0.0.1 6379 > keys *
1) "myset"
2) "mysortset"
Redis 127.0.0.1 6379 > select 1
OK
Redis 127.0.0.1 redis [1] > config get requirepass
1) "requirepass"
2) "myRedis"
Redis 127.0.0.1 redis [1] > config set requirepass my_redis
OK
Redis 127.0.0.1 redis [1] > config get requirepass
1) "requirepass"
2) "my_redis"
No need to restart redis
If you log in to redis with the old password configured in the configuration file in step 1, you will find that the original password is no longer available and the operation is rejected.
Redis-cli-h 127.0.0.1-p 6379-a myRedis
Redis 127.0.0.1 6379 > config get requirepass
(error) ERR operation not permitted
Log in to redis with the modified password, and you can perform the appropriate actions
Redis-cli-h 127.0.0.1-p 6379-a my_redis
Redis 127.0.0.1 6379 > config get requirepass
1) "requirepass"
2) "my_redis
Try to restart redis, log in to redis with the newly configured password and find that the new password is invalid. Redis reuses the password in the configuration file.
Sudo service redis restart
Stopping redis-server: [OK]
Starting redis-server: [OK]
Redis-cli-h 127.0.0.1-p 6379-a my_redis
Redis 127.0.0.1 6379 > config get requirepass
(error) ERR operation not permitted
Redis-cli-h 127.0.0.1-p 6379-a myRedis
Redis 127.0.0.1 6379 > config get requirepass
1) "requirepass"
2) "myRedis"
In addition to setting a password through the-a parameter when logging in, you can also log in without specifying a password and authenticate before performing an operation.
Redis-cli-h 127.0.0.1-p 6379
Redis 127.0.0.1 6379 > config get requirepass
(error) ERR operation not permitted
Redis 127.0.0.1 6379 > auth myRedis
OK
Redis 127.0.0.1 6379 > config get requirepass
1) "requirepass"
2) "myRedis"
3.master is configured with a password, how to configure slave
If master is configured with a password, slave must also configure the corresponding password parameters, otherwise it will not be able to copy normally.
Find the following line in the configuration file in slave. Remove the comment and change the password.
# masterauth mstpassword
At this point, I believe that everyone on the "Redis how to configure authentication password" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Kingdba1: first, RAC system structure design.
© 2024 shulou.com SLNews company. All rights reserved.