Linux 安装redis5.0.7 设置密码,开启远程访问

官网
https://redis.io/download

安装
使用以下命令下载,提取和编译(需要GCC)Redis:
[root@localhost tmp]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
[root@localhost tmp]# tar xzf redis-5.0.7.tar.gz
[root@localhost tmp]# cd redis-5.0.7
[root@localhost redis-5.0.7]# make

指定配置文件运行Redis:
[root@localhost redis-5.0.7]# src/redis-server redis.conf

客户端与Redis进行交互:
[root@localhost redis-5.0.7]# src/redis-cli -h 127.0.0.1 -p 6379

设置密码
找到requirepass一行,去掉注释 设置密码(requirepass 密码)
连接:[root@localhost redis-5.0.7]# src/redis-cli -h 127.0.0.1 -p 6379 -a 密码

远程访问
修改redis.conf 配置文件
protected-mode后的yes改为no
找到bind 127.0.0.1注释掉(或改为0.0.0.0)
开放端口6379(防火墙、阿里云安全策略。。。)

常见问题
远程连接时可能出现DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified…
解决方法:启动服务时要加上配置文件Linux:src/redis-server redis.cnf(Windows:redis-server.exe redis.windows.conf)

后台运行
daemonize yes 表示允许后台运行
(./src/redis-server redis.conf &(启动服务是加&后缀表示后台运行))

安装wget
yum -y install wget

安装gcc
yum install gcc-c++ -y

命令
[root@localhost redis-5.0.7]# ./src/redis-server
or
[root@localhost redis-5.0.7]# src/redis-server

你可能感兴趣的:(nosql,redis)