php密码连接redis

来源:互联网 发布:假短信软件 编辑:程序博客网 时间:2024/06/12 18:13

增加redis密码,配置文件/usr/local/redis/etc/redis6001.conf中增加 requirepass pt#1234@re

连接操作:

[root@10.0.3.85 bin]# cd/usr/local/redis/bin

[root@10.0.3.85 bin]# ./redis-server../etc/redis6001.conf

[root@10.0.3.85 bin]# ./redis-cli -h127.0.0.1 -p 6001 -a pt#1234@re

php连接:

[php] view plain copy
  1. <?php  
  2.    $redis = new Redis();  
  3.    $redis->connect('127.0.0.1', 6001);  
  4.    $redis->auth('pt#1234@re');  
  5.    $redis ->set( "test" , "Hello World");  
  6.    echo $redis ->get( "test");  
  7. ?>  

0 0