一般配置情况下,在远程服务器上使用redis时,首先需要找到配置文件redis.conf。我这里的配置文件的目录为:/etc/redis.conf。
修改配置文件:vi /etc/redis.conf
-
将
bind 127.0.0.1改成了bind 0.0.0.0或者#注释掉bind 127.0.0.1 -
将
protected-mode yes修改为:protected-mode no 但是在这种情况下,你需要先运行你的配置文件: source /etc/redis.conf,再启动redis :redis-cli ,之后在redis中设置密码:CONFIG set requirepass “redis数据库密码” ,一旦重启数据库,重启的为默认的redis数据库,这个时候,你需要重新使你的数据库配置文件生效,就要再按照 :source /etc/redis.conf ,redis-cli ,CONFIG set requirepass “redis数据库密码” 再进行重复操作。
因此,我们可以指定通过配置文件进行启动,具体操作如下:
- 将
bind 127.0.0.1改成了bind 0.0.0.0或者#注释掉bind 127.0.0.1 - 将
protected-mode yes修改为:protected-mode no - 将
daemonize no修改为:daemonize yes - 在配置文件中加入设置redis密码的语句(找到文件中
requirepass一词的位置):requirepass '你的redis数据库密码' - 在你的远程服务器上找到redis-server所在位置
- 将
启动redis数据库:redis-server /etc/redis.conf
本文详细介绍了如何在远程服务器上配置Redis,包括修改配置文件使Redis监听所有IP地址,关闭保护模式,设置密码,以及如何通过配置文件启动Redis服务。
1411

被折叠的 条评论
为什么被折叠?



