安装
Windows
Github下载地址:https://github.com/MicrosoftArchive/redis/releases
下载对应的.msi
版本安装即可
Linux
centos7使用yum安装Redis时,可能会有安装源的问题出现
安装epel源,CentOS默认的安装源在官方的centos.org上,而redis在第三方的yum源里,因此无法安装。这就是我们常常在yum源里找不到各种软件的原因,还需要自己去wget,然后configure,make,make install,这个过程太痛苦了,并且卸载软件的时候还容易出错
非官方的yum推荐用fedora的epel仓库
yum添加epel源的命令为:yum install epel-release
然后回车
1 | yum install epel-release |
Docker
1 | # 不设置密码(没法通过 "docker update ..." 追加密码) |
设置(重置)密码
输入Redis命令:会提示
(error) NOAUTH Authentication required.
这是属于正常现象。我们输入:
auth 123456
再次输入Redis命令即可正常使用
Windows
找到Redis安装目录,打开
redis.windows.conf
和redis.windows-service.conf
并找到# requirepass foobared
这一行,在这一行下面增加一行requirepass 你的密码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
requirepass 123456保存,重启Redis服务
Linux
编辑文件
/etc/redis.conf
1
2
3
4vi /etc/redis.conf
# requirepass foobared下一行加上以下内容:
requirepass 123456效果如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15################################## SECURITY ###################################
# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
requirepass 123456保存,重启Redis服务
1
systemctl restart redis
Docker
1 | docker run -d --name redis -p 6379:6379 redis --requirepass "123456" |