2

Redis的安装与配置

 1 month ago
source link: https://www.cnblogs.com/yuey6670/p/18046746
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Ubuntu22.04安装

本操作在虚拟机上

安装Redis

1)更新系统

sudo apt update
sudo apt upgrade

2)安装Redis

sudo apt install redis-server

3)测试Redis是否工作

redis-cli --version
systemctl status redis
# 注意:如果你的服务器上仅用了ipv6,将会启动失败。

4)登入redis-cli

redis-cli

配置Redis远程连接

我们只需要修改配置文件即可。

sudo vim /etc/redis/redis.conf #打开redis的配置文件
bind 127.0.0.1 ::1注释掉

protected-mode改成no

#取消注释requirepass 启动密码认证,并设置访问密码
requirepass your-pass-word

# 以守护进程运行Redis 
daemonize yes

注:vim,在命令行的模式下,/words,查找,敲回车,如果想继续查找此关键词,敲字符n继续寻找。

配置完成后,保存并关闭文件,然后重启Redis

systemctl restart redis-server

在连接服务器界面中,输入远程Redis服务器的IP、Port和配置好的密码,点击Save确认连接。Redis连接后,就可操作Redis数据了。

windows安装

redis下载地址:Releases · tporadowski/redis (github.com)

选择zip下载,并将文件解压缩到指定位置。

并为其配置环境变量

address:
D:\software\Redis\Redis-x64-5.0.14.1 #存放在path中

1)启动redis服务

redis-server.exe

2)测试连接

# 在另一个窗口测是否连接
# 在命令中输入ping命令来检测redis服务器与redis客户端的连通性,返回PONG则说明连接成功了
->redis-cli.exe -h 127.0.0.1 -p 6379
->ping
# pong
->exit
#退出redis

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK