How to change the Redis password: Stop the Redis service. Create the password file redis.conf and add requirepass new_password. Save and start the Redis service. Use -a new_password to connect to Redis to verify the password.
How to change the Redis password
Steps to change the Redis password:
1. Stop the Redis service:
<code>$ sudo systemctl stop redis-server</code>
2. Create a password file:
Use a text editor (such as nano or vi) to create a file named A new file for redis.conf
. Add the following lines to the end of the file, where new_password
is the new password you want to set:
<code>requirepass new_password</code>
3. Save the password file:
replace The redis.conf
file is saved to the Redis configuration directory, usually /etc/redis/
.
4. Start the Redis service:
<code>$ sudo systemctl start redis-server</code>
5. Connect to Redis and verify the password:
Use the following commands to connect to Redis and Test password:
<code>$ redis-cli -a new_password</code>
If the prompt changes to redis>
, the password is changed successfully.
Note:
new_password
with the new password you wish to set. The requirepass
directive sets a password that must be provided to connect to Redis. The above is the detailed content of How to change the password in redis. For more information, please follow other related articles on the PHP Chinese website!