Redis password management

Source: Internet
Author: User
Tags redis cluster install redis

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, which is the parameter for configuring the redis access password.
 
For example, requirepass test123
 
B. If the parameters in the configuration file take effect, restart redis.
 
 
 
2. How do I configure the password without restarting redis?
 
A. Configure the requirepass password in the configuration file (the password is still valid when redis is restarted ).
 
# Requirepass foobared
If changed:
 
Requirepass test123
 
 
 
B. Enter redis redefinition Parameters
 
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
1) "requirepass"
2) (nil)
 
Show that the password is empty,
 
Then set the password:
 
Redis 127.0.0.1: 6379> config set requirepass test123
OK
 
Query the password again:
 
Redis 127.0.0.1: 6379> config get requirepass
(Error) ERR operation not permitted
 
An error is reported!
 
Now you only need password authentication.
 
Redis 127.0.0.1: 6379> auth test123
OK
 
Query the password again:
 
Redis 127.0.0.1: 6379> config get requirepass
1) "requirepass"
2) "test123"
 
The password has been modified.
 
When redis can be restarted, the password will automatically take effect because the configuration parameters have been modified.
 
If no password is added to the configuration parameter, the password for redis restart is equivalent to not set.
 
 
 
3. How do I log on to redis with a password?
 
A. Enter the password when logging on.
 
[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
1) "requirepass"
2) "test123"
 
 
 
B. log on 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
1) "requirepass"
2) "test123"
Redis 127.0.0.1: 6379>
 
 
 
4. The master has a password. How can I configure slave?
 
When the master node has a password and slave is configured, the corresponding Password parameters must be configured accordingly. Otherwise, slave cannot be copied normally.
 
The corresponding parameters are:
 
# Masterauth
 
For example:
 
Masterauth mstpassword

Install and test Redis in Ubuntu 14.04

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Redis. conf

Redis details: click here
Redis: click here

This article permanently updates the link address:

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.