Redis设置密码-创新互联

一、设置方法: 方法一:通过命令设置密码(临时生效,重启服务器后密码失效)

使用redis-cli连接上redis,执行如下命令:

为澄江等地区用户提供了全套网页设计制作服务,及澄江网站建设行业解决方案。主营业务为成都网站设计、网站建设、澄江网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
config set requirepass 123456

执行完毕,无需重启,退出客户端,重新登录就需要输入密码了 

方法二:通过配置文件redis.conf设置密码(永久生效)

vi编辑器打开redis.conf

[root@localhost /]# vi /etc/redis.conf

输入/requirepass 找到requirepass关键字,后面跟的就是密码,默认是注释掉的,即不需要密码

# The requirepass is not compatable with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.
#
# requirepass foobared

注释打开,后面修改为自己的密码

# The requirepass is not compatable with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.
#
 requirepass 123456

wq保存退出,重启服务器即可

二、连接方法:

1.连接时输入密码:

[root@localhost bin]# ./redis-cli -a 123456

2.先连接再输入密码:

[root@localhost bin]# ./redis-cli
127.0.0.1:6379>auth 123456
三、关闭方法:
[root@localhost bin]# ./redis-cli -a 123456 shutdown

重启后打开:

[root@localhost etc]# cd /usr/local/bin
[root@localhost bin]# redis-server /etc/redis.conf 
[root@localhost bin]# ps -ef|grep redis
root       7650   7491  0 18:36 pts/1    00:00:00 /usr/local/bin/redis-cli
root      12277      1  0 19:53 ?        00:00:00 redis-server 127.0.0.1:6379
root      12295   7156  0 19:53 pts/0    00:00:00 grep --color=auto redis
[root@localhost bin]# redis-cli
127.0.0.1:6379>auth 123456
OK

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


当前文章:Redis设置密码-创新互联
转载注明:http://myzitong.com/article/cogodj.html