处理python连接redis出现的问题

处理python连接redis出现的问题,第1张

处理python连接redis出现的问题

一。刚开始连接redis

问题如下:redis.exceptions.ResponseError: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'ConFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use ConFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

代码如下:

原因:redis运行在受保护模式,需要redis命令行下作设置:config set protected-mode no

解决办法:

需要在redis的客户端命令行下

redis-cli

受保护模式为no

config get protected-mode

config set protected-mode no

设置密码

config set requirepass 123456

二。 Error:Invalid input of type: 'dict'. Convert to a bytes, string, int or float first.

python的第三方包redis版本高了

pip install redis==2.10.6

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5070964.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存