使用pycharm安装redis包

python链接redis_重启

import redis

try:
    r=redis.StrictRedis(host='192.168.124.154', port=6379 ,db=0,password='luxing')
    r.set('name','hello')
    r.get('name')
    print r.get('name')
except Exception,e:
    print e.message

1、报错,AttributeError: 'module' object has no attribute 'StrictRedis' 

可能是你python文件的名称你也叫做redis导致的,将python重新命名就行

2、Error 10061 connecting to 192.168.3.99:6379

可能是因为redis.conf文件修改,而redis没有重启,

3、DENIED Redis is running in protected mode because prote代码链接不上,很可能是你配置文件中的配置没有改,如秘密、访问ip的绑定、还有就是redis是保护状态启动

一、

1)打开配置文件把下面对应的注释掉
# bind 127.0.0.1 

2)Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程,设置为no
daemonize no

3)在对应配置conf文件中去掉注释,把yes改为no

#protected-mode yes
protected-mode no

二、添加认证,设置密码

# requirepass foobared

requirepass redis123456