Using CentOS 6.x, for applying Password Authentication in Redis through requirepass Configuration, we need to edit the redis.conf file.
Open the configuration file(name of the file may vary in your machine):
/etc/redis/6379.conf
Find
# requirepass foobared and change it in following way:
Save your changes and restart redis-server
1 | service redis_6379 restart
|
1 | 127.0.0.1:6379> set test "TestEntry"
|
Since we have applied password in Redis Configurtion file "/etc/redis/6379.conf" , we will get NOAUTH error as follows:
1 | (error) NOAUTH Authentication required.
|
while being in redis-cli, write following command with your password for authentication:
1 2 | 127.0.0.1:6379> auth yourpassword
OK
|
And then when you will set any value, it will return OK
1 2 | 127.0.0.1:6379> set test "TestEntry"
OK
|
We can also run redis-cli directly with password authentication by using following command:
1 | redis-cli -a "yourpassword"
|
We get OK when we run redis-cli in this way and set any value:
1 2 | 127.0.0.1:6379> set test2 "TestEntry2"
OK
|
No comments:
Post a Comment