Redis Configuration Authentication Password

Source: Internet
Author: User

Redis Configuration Password

1. Configuring with configuration Files
The Yum-style installation of Redis profiles is typically in/etc/redis.conf, which opens the configuration file to find
#requirepass foobared
Remove the comment before the line, and change the password to the desired password, save the file
Requirepass Myredis
Restart Redis
sudo service Redis restart# or sudo service Redis Stopsudo redis-server/etc/redis.conf
This is the time to try to log in to Redis and find that it is possible to mount, but the specific command is prompt operation is not allowed
Try to log in with a password and execute a specific command to see that it can be executed successfully
Redis-cli-h 127.0.0.1-p 6379-a Myredisredis 127.0.0.1:6379> keys *) "MySet" 2) "Mysortset" Redis 127.0.0.1:6379> S Elect 1OKredis 127.0.0.1:6379[1]> config get requirepass1) "Requirepass" 2) "Myredis"


2. Configure through the command line

Redis 127.0.0.1:6379[1]> config set requirepass my_redisokredis 127.0.0.1:6379[1]> config get Requirepass1) " Requirepass "2)" My_redis "
No need to restart Redis
Using the old password configured in the configuration file in the first step to sign in to Redis, you will find that the original password is not available and the operation is rejected

Redis-cli-h 127.0.0.1-p 6379-a Myredisredis 127.0.0.1:6379> config get Requirepass (error) ERR operation not Permitte D
Log in to Redis with the modified password to perform the appropriate action
Redis-cli-h 127.0.0.1-p 6379-a My_redisredis 127.0.0.1:6379> config get requirepass1) "Requirepass" 2) "My_redis
Try to restart Redis, log in to Redis with the newly configured password, discover that the new password is invalid, and Redis re-uses the password in the configuration file
sudo service Redis restartstopping redis-server:                                     [  OK  ]starting redis-server:                                     [  OK  ] Redis-cli-h 127.0.0.1-p 6379-a My_redisredis 127.0.0.1:6379> config get Requirepass (error) ERR operation not Permitt Edredis-cli-h 127.0.0.1-p 6379-a Myredisredis 127.0.0.1:6379> config get requirepass1) "Requirepass" 2) "Myredis"

In addition to setting a password with the-a parameter at login, you can log in without specifying a password and authenticate before performing the operation.
Redis-cli-h 127.0.0.1-p 6379redis 127.0.0.1:6379> config get Requirepass (error) ERR operation not Permittedredis 127. 0.0.1:6379> auth Myredisokredis 127.0.0.1:6379> config get requirepass1) "Requirepass" 2) "Myredis"


3.master configured the password, slave how to configure

If master is configured with a password, slave must also configure the appropriate password parameters otherwise it will not be able to replicate normally.
Locate the following line in the config file in slave, remove the comment, and change the password
#masterauth  Mstpassword


Redis Configuration Authentication Password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.