Centos安装Redis

0 篇文章 0 订阅

一、系统版本

  • Linux:CentOS Linux release 7.6.1810 (Core)
  • Redis:3.2.12

二、安装Redis

// 1.使用yum安装redis
[root@localhost ~]# yum -y install redis

// 2.启动redis
[root@localhost ~]# systemctl start redis

// 3.查看redis状态(如果Active为active(running)表示安装成功)
[root@localhost ~]# systemctl status redis

三、测试Redis

// 4.进入redis
[root@localhost ~]# redis-cli
127.0.0.1:6379> set 'test' 'hello'
OK
127.0.0.1:6379> get 'test' 
"hello"

四、配置Redis

1、搜索配置文件
[root@localhost ~]# whereis redis.config
redis: /etc/redis.conf
2、编辑配置文件
#允许远程访问
#bind 127.0.0.1

#端口号
port 6379

#设置密码
requirepass 666666

#关闭保护
protected-mode no
3、重启Redis服务
[root@localhost ~]# systemctl restart redis

五、远程连接Redis

使用 PowerShell / CMD 连接
 // 这里的127.0.0.1请改为自己服务器的ip地址,6379改为自己的端口
 C:\WINDOWS\system32> redis-cli -h 127.0.0.1  -p  6379
 
 // 这里直接获取key值结果报错,需要先登录一下
 127.0.0.1:6379> get 'test' 
 (error) NOAUTH Authentication required.
 
 // 登录Redis
 127.0.0.1:6379> auth 666666
 OK
 
 // 再次获取key值,发现已经能获取了,就是上面设置的
 127.0.0.1:6379> get 'test' 
 "hello"
使用 Redis Desktop Manager 连

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值