Redis 安装与配置

一、安装 Redis

1.1、Windows 安装 Redis

Redis 最新版不支持 Windows 系统,建议在 Linux 上安装。如果硬要在 Windows 上使用 Redis,可以在 WSL 中安装,或者安装 Redis 的早期版本:https://github.com/MicrosoftArchive/redis/releases。

1.2、Centos 安装 Redis

Centos 可以用源码安装,具体步骤如下:

wget https://download.redis.io/redis-stable.tar.gz
tar -xzvf redis-stable.tar.gz
cd redis-stable
make && make install

可执行文件默认安装在 /usr/local/bin 目录下

1.3、其它系统安装 Redis

参考官方文档:https://redis.io/docs/getting-started/installation/

二、Redis 相关配置

2.1、配置文件

Redis 的配置文件在解压后的目录中,名为 redis.conf。终端启动 redis-server 使用默认的配置文件,如果要指定配置文件需要在其后加上配置文件路径。

redis-server /path/to/redis.conf

2.2、允许其它主机连接

在配置文件中搜索 bind 127.0.0.1,找到后将这一行注释掉

image-20220820095056711

2.3、设置连接密码

在配置文件中搜索 requirepass,找到后取消其注释,在其后替换为自己的密码

image-20220820095338420

2.4、允许在后台运行

在配置文件中搜索 daemonize,找到后将其后 no 改为 yes

image-20220820095942094

2.5、注意事项

如果开启了防火墙,需要开放 6379 端口

firewall-cmd --add-port=6379/tcp --permanent
firewall-cmd --reload

在本地连接时,也要指定密码,否则会出现没有权限的错误

image-20220820100403492

redis-cli -a password

三、安装 GUI 客户端

有一款跨平台的软件叫:RESP(之前叫 Redis Desktop Manager),是开源软件,在 Linux 上是免费的。但在 MacOS 和 Windows 上收费,大概 99¥ 永久使用。

还有热心网友自己编译的版本,可以免费使用:https://github.com/lework/RedisDesktopManager-Windows

连接步骤:

image-20220820103508766

image-20220820103726692

posted @ 2022-08-20 10:41  王舰  阅读(706)  评论(0编辑  收藏  举报