How to set password for redis

To set the password for redis server, edit your configuration file, by default, at “/etc/redis/redis.conf”

vi /etc/redis/redis.conf

then search this phrase: “requirepass foobared” in the config file. Then uncomment this line, change foobared to any password you need. For example:

requirepass thisIsTh3l0ngestPas2w0rd?

Now save the config file, restart redis with this command to apply changes:

systemctl restart redis

Check again to make sure redis running ok:

systemctl status redis