1.安全实现:
采用绑定IP的方式来进行控制,在redis.conf文件找到如下配置在bind后修改为需要绑定的ip即可,如不需要则最好用#注释:
If you want you can bind a single interface, if the bind option is not specified all the interfaces will listen for incoming connections.
bind 127.0.0.1
注意: 这种情况下,我们在启动redis服务器的时候不能单单使用:redis-server,应改为:redis-server path/redis.conf 即在启动的时候指定需要加载的配置文件(path需修改为实际路径)
设置密码,以提供远程登陆
打开redis.conf配置文件,找到requirepass
requirepass yourPassword
确保防火墙关闭,或者已开放供访问的端口
设置临时密码,在关闭redis后失效 –不常用未验证
config set requirepass yourPassword
如果忘了密码 启动redis -cli后命令行输入:
config get requirepass