服务器Redis修改密码
1. 打开终端(Terminal)
2. 使用以下命令编辑 Redis 配置文件 redis.conf
sudo vim /etc/redis/redis.conf
3. 在 redis.conf
文件中,查找并定位到 # requirepass foobared
这一行。可以通过按下 /
并输入 # requirepass
来进行搜索。
4. 将 # requirepass
行的注释符 #
去掉,并在 foobared
的位置设置你想要的密码。例如:
requirepass your_password
请将 your_password
替换为你自己的密码。
5. 保存并关闭文件。
6. 重启 Redis 服务以使配置更改生效:
sudo systemctl restart redis-server
现在,Redis 已被配置为需要密码进行访问。
7. 验证
redis-cli -a your_password
将 your_password
替换为你设置的密码。