NoSQL 数据库案例实战 --Redis 密码防护

Redis 密码防护

前言

本环境是基于 Centos 7.8 系统构建Redis学习环境
具体构建,请参考 Redis-5.0.9环境部署

给 redis 服务器设置密码,这样客户端连接到 redis 服务就需要密码验证,这样可以让你的 redis 服务更安全。


产看redis密码

192.168.5.12:6379> config get requirepass
1) "requirepass"
2) ""

临时设定

192.168.5.12:6379> config set requirepass '123'
OK
192.168.5.12:6379> auth 123
OK
192.168.5.12:6379> config get requirepass
1) "requirepass"
2) "123"

永久设定

[root@reids_source_code ~]# vim /etc/redis/redis.conf 
[root@reids_source_code ~]# systemctl restart redis
# 登录一
[root@reids_source_code ~]# redis-cli -h 192.168.5.12 
192.168.5.12:6379> auth 123
OK
192.168.5.12:6379> config get requirepass
1) "requirepass"
2) "123"
# 登录二
[root@reids_source_code ~]# redis-cli -h 192.168.5.12 -a 123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.5.12:6379> config get requirepass
1) "requirepass"
2) "123"

注:redis服务密码明文保存

猜你喜欢

转载自blog.csdn.net/XY0918ZWQ/article/details/113803035