Linux中如何设置访问redis 您所在的位置:网站首页 linux连接redis密码 Linux中如何设置访问redis

Linux中如何设置访问redis

#Linux中如何设置访问redis| 来源: 网络整理| 查看: 265

Linux中如何设置访问redis-server的密码? 发布时间:2020-05-25 15:03:59 来源:亿速云 阅读:264 作者:鸽子 栏目:关系型数据库

今天服务器安装了redis,为了安全设置一下访问redis-server的密码。

一、查找redis.conf文件

我们服务器已经安装了redis,现在通过命令查看下redis的进程:

[root@lnp ~]# ps -aux|grep redis root 7374 0.0 0.0 145312 7524 ? Ssl 16:37 0:00 redis-server 192.168.17.105:6379 root 10692 0.0 0.0 112724 984 pts/7 S+ 16:54 0:00 grep --color=auto redis

可以看到我们的redis-server的服务地址为192.168.17.105,端口为6379,对外访问的时候需要指定对应的IP和端口:

redis-cli -h 192.168.17.105 -p 6379

查找redis安装目录

> whereis redis redis: /usr/local/redis

我们可以看到redis在该目录下安装,然后找到配置文件redis.conf

> find /usr/local/redis/ -name redis.conf /usr/local/redis/etc/redis.conf

修改配置文件:

vim redis.conf

改该配置文件即可:

# requirepass foobared requirepass 123 指定密码123

最后一步,重新加载配置文件即可:

redis-server /usr/local/redis/etc/redis.conf

二、连接测试

通过密码-a访问:

> redis-cli -h 192.168.17.105 -p 6379 -a 123

运行结果:

[root@lnp etc]# redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused Could not connect to Redis at 127.0.0.1:6379: Connection refused not connected> exit [root@lnp etc]# redis-cli -h 192.168.17.105 -p 6379 192.168.17.105:6379> keys * (error) NOAUTH Authentication required. 192.168.17.105:6379> exit [root@lnp etc]# redis-cli -h 192.168.17.105 -p 6379 -a 123 Warning: Using a password with '-a' option on the command line interface may not be safe. 192.168.17.105:6379> keys * (empty list or set) 192.168.17.105:6379> exit

以上就是Linux下设置redis访问密码的方法的详细内容,更多请关注亿速云其它相关文章!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:[email protected]进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

redis linux edi 上一篇新闻:javascript实现函数防抖与节流 下一篇新闻:java用什么软件开发? 香港云服务器 10000元红包免费领

红包可用于(云服务器、高防服务器、裸金属服务器、高防IP、云数据库、CDN加速)购买和续费

猜你喜欢 redis的scan语法及作用对象 Redis中GETBIT和SETBIT的详细介绍 什么是Redis以及其作用 Redis为何速度这么快 redis的incr和hash应用是怎样的 Redis的应用场景都是怎样的 redis中aof和rdb是什么以及两者区别有哪些 Redis Cluster到底会不会丢数据 Redis中热点Key如何产生的 什么是Cluster以及Redis中为什么需要Cluster


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有