sudo cp redis.conf /usr/local/redis/ cd /user/local/redis sudo vi redis.conf
修改第一处,bind 127.0.0.1(只限制了本地访问我们需要远程)改为
1
bind0.0.0.0
修改第二处 daemonize no (前台启动方式)改为yes后台启动
1
daemonizeyes
修改第三处 # requirepass foobared 密码(打开注释)
1
requirepass123456
还可以指定日志文件,默认为空
1
logfile /var/log/redis/redis-server.log
指定配置文件启动
1 2
cd bin ./redis-server ../redis-conf
链接
1
./redis-cli -p6379 -a123456
之后就可以在命令行中插入数据了
常见错误
启动几分钟后,无法连接redis,并且有以下错误信息
1
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.