import redis
r=redis.Redis(host='192.168.56.102',port=6379,db=0,password='jinxfredis' )
r.set('name','jin')
print(r.get('name'))

Python远程连接Redis时报如下错误:

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在保护模式下运行,因为保护模式是启用的,没有指定绑定地址,没有向客户端请求身份验证密码。在这种模式下,连接只能从环回接口接受。如果你想从外部计算机连接到复述,你可能采取的解决方案:

1)只是禁用保护模式发送命令的配置设置保护模式没有从loopback接口连接到复述同一主机服务器正在运行,然而确保复述,不是公开从互联网访问如果你这样做。使用配置重写使此更改永久存在。

2)也可以通过编辑Redis配置文件,将protected模式选项设置为no,然后重新启动服务器,从而禁用protected模式。

3)如果您只是为了测试而手动启动服务器,那么使用“—保护模式no”选项重新启动服务器。

4)设置绑定地址或身份验证密码。注意:为了让服务器开始接受来自外部的连接,您只需要做上述的一件事。

按照上面2-4设置后,

bind 0.0.0.0

protected-mode no

   requirepass password

从新启动Redis,还是报相同的错误。。。

原来Redis不指定配置文件,就按照默认的设置启动,所以重新启动Redis时,设置指定的配置文件,远程就可以正常访问了

[root@localhost ~]# redis-server redis-3.2/redis.conf 

Python远程连接Redis的更多相关文章

  1. Python 使用Python远程连接并操作InfluxDB数据库

    使用Python远程连接并操作InfluxDB数据库 by:授客 QQ:1033553122 实践环境 Python 3.4.0 CentOS 6 64位(内核版本2.6.32-642.el6.x86 ...

  2. 项目总结14:Windows远程连接redis(cmd指令或PowerShell指令)

    1-确认远程的redis服务器是否允许被远程连接,已redis server安装在阿里云ECS上为例 1-1-确认在阿里云控制台,开放了端口6379和允许访问的IP 1-2-确认在服务器上安装redi ...

  3. Python远程连接模块-Telnet

    Python远程连接模块-Telnet 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 虽然现在主流的python版本还是2.7,相信2020年python程序员都会偏向Python ...

  4. 用 Redis Desktop Manager 远程连接 redis 数据库。

    环境: 本机OS:window 10(本机没有安装redis) redis 服务器:centos 7 使用 Redis Desktop Manager 工具远程连接 redis. Redis Desk ...

  5. python远程连接paramiko 模块和堡垒机实现

    paramiko使用 paramiko模块是基于python实现了SSH2远程安全连接,支持认证和密钥方式,可以实现远程连接.命令执行.文件传输.中间SSH代理功能 安装 pip install pa ...

  6. 远程连接redis

    1.在ubuntu上的redis作为服务端,默认是打开的 在redis的配置文件redis.conf中,找到bind localhost注释掉. 注释掉本机,局域网内的所有计算机都能访问. bind ...

  7. Redis系列-远程连接redis并给redis加锁

    假设两台redis服务器,ip分别为:192.168.1.101和192.168.1.103,如何在101上通过redis-cli访问103上的redis呢?在远程连接103之前,先讲下redis-c ...

  8. win8.1远程连接Redis数据库

    环境:redis安装在虚拟机Centos6.5系统上 通过java远程连接 问题一:报错 connected refused redis.conf 注释掉 #bind 127.0.0.1 问题二:还是 ...

  9. Redis系列-远程连接redis

    假设两台redis服务器,ip分别为:192.168.1.101和192.168.1.103,如何在101上通过redis-cli访问103上的redis呢?在远程连接103之前,先讲下redis-c ...

随机推荐

  1. 技术分享丨数据仓库的建模与ETL实践技巧

    摘要:如何搭建数据仓库,在这个过程中都应该遵循哪些方法和原则,项目实践中有哪些技巧. 一.数据仓库的“心脏” 首先来谈谈数据模型.模型是现实世界特征的模拟和抽象,比如地图.建筑设计沙盘,飞机模型等等. ...

  2. jq js 获取子元素

    js this.children[1].className=""this.firstChild.className = ""this.lastChild.cla ...

  3. SpringMVC使用Session

    Session在用户登录,一些特殊场合在页面间传递数据的时候会经常用到 @ 目录 修改IndexController check.jsp 效果 修改IndexController 映射 /check ...

  4. Gitlab安装使用

    Gitlab安装使用 1. 为什么要使用gitlab Git的优点多多这里就不详细介绍了: Git是版本控制系统,Github是在线的基于Git的代码托管服务: Github有个小缺陷 (也不能算是缺 ...

  5. RabbitMQ set password

    问题: -- ::09.387 ERROR oslo.messaging._drivers.impl_rabbit [req-51faf017-4f1f-4a24-ab79-624b302b839b ...

  6. 基于 abp vNext 微服务开发的敏捷应用构建平台 - 文章目录

    系列文章: <基于 abp vNext 微服务开发的敏捷应用构建平台 - 设计构想> [点击查看] <基于 abp vNext 微服务开发的敏捷应用构建平台 - 文章目录> [ ...

  7. 多线程std::cout 深入研究

    1.研究背景 在测试时发现mingw版本的gcc编译出来的程序,一个主程序新建20个线程,每个线程都循环向cout输出信息,几分钟程序就崩了,而用msvc和gcc-linaro版gcc交叉编译器编译出 ...

  8. JavaScript闭包(内存泄漏、溢出以及内存回收),超直白解析

    1 引言 变量作用域 首先我们先铺垫一个知识点--变量作用域: 变量根据作用域的不同分为两种:全局变量和局部变量. 函数内部可以使用全局变量. 函数外部不可以使用局部变量. 当函数执行完毕,本作用域内 ...

  9. C++中的快读和快写

    快读原理 单个字符的读入速度要比读入数字快,因此我们以字符的形式先读入,然后处理计算转为数字. 代码 inline int read(){ register int x = 0, t = 1; reg ...

  10. 手写Promise看着一篇就足够了

    目录 概要 博客思路 API的特性与手写源码 构造函数 then catch Promise.resolved Promise.rejected Promise.all Promise.race 概要 ...