I\'m working with redis on my local machine so I dont really need to set up a password to connect to the server with my php client (I\'m using predis as a client). However, I\'
For that, you need to update the redis configuration file.By default, there is no any password for redis.
01) open redis configuration file
sudo vi /etc/redis/redis.conf
find requirepass field under SECURITY section and uncomment that field.Then set your password instead of "foobared"
# requirepass foobared
It should be like,
requirepass YOUR_PASSWORD
Then restart redis and start redis-cli.
If you need to check whether you have set the password correctly, you can run below commads in redis-cli.
sithara@sithara-X555UJ ~ $ redis-cli
127.0.0.1:6379> set key1 18
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth admin
OK
127.0.0.1:6379> get key1
(nil)
127.0.0.1:6379> exit
sithara@sithara-X555UJ ~ $ redis-cli
127.0.0.1:6379> set key1 18
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth admin
OK
127.0.0.1:6379> set key2 check
OK
127.0.0.1:6379> get key2
"check"
127.0.0.1:6379> get key1
(nil)
127.0.0.1:6379> set key1 20
OK
127.0.0.1:6379> get key1
"20"
127.0.0.1:6379> exit
`