Python远程连接Redis
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的更多相关文章
- Python 使用Python远程连接并操作InfluxDB数据库
		使用Python远程连接并操作InfluxDB数据库 by:授客 QQ:1033553122 实践环境 Python 3.4.0 CentOS 6 64位(内核版本2.6.32-642.el6.x86 ... 
- 项目总结14:Windows远程连接redis(cmd指令或PowerShell指令)
		1-确认远程的redis服务器是否允许被远程连接,已redis server安装在阿里云ECS上为例 1-1-确认在阿里云控制台,开放了端口6379和允许访问的IP 1-2-确认在服务器上安装redi ... 
- Python远程连接模块-Telnet
		Python远程连接模块-Telnet 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 虽然现在主流的python版本还是2.7,相信2020年python程序员都会偏向Python ... 
- 用 Redis Desktop Manager 远程连接 redis 数据库。
		环境: 本机OS:window 10(本机没有安装redis) redis 服务器:centos 7 使用 Redis Desktop Manager 工具远程连接 redis. Redis Desk ... 
- python远程连接paramiko 模块和堡垒机实现
		paramiko使用 paramiko模块是基于python实现了SSH2远程安全连接,支持认证和密钥方式,可以实现远程连接.命令执行.文件传输.中间SSH代理功能 安装 pip install pa ... 
- 远程连接redis
		1.在ubuntu上的redis作为服务端,默认是打开的 在redis的配置文件redis.conf中,找到bind localhost注释掉. 注释掉本机,局域网内的所有计算机都能访问. bind ... 
- Redis系列-远程连接redis并给redis加锁
		假设两台redis服务器,ip分别为:192.168.1.101和192.168.1.103,如何在101上通过redis-cli访问103上的redis呢?在远程连接103之前,先讲下redis-c ... 
- win8.1远程连接Redis数据库
		环境:redis安装在虚拟机Centos6.5系统上 通过java远程连接 问题一:报错 connected refused redis.conf 注释掉 #bind 127.0.0.1 问题二:还是 ... 
- Redis系列-远程连接redis
		假设两台redis服务器,ip分别为:192.168.1.101和192.168.1.103,如何在101上通过redis-cli访问103上的redis呢?在远程连接103之前,先讲下redis-c ... 
随机推荐
- myBatis源码解析-反射篇(4)
			前沿 前文分析了mybatis的日志包,缓存包,数据源包.源码实在有点难顶,在分析反射包时,花费了较多时间.废话不多说,开始源码之路. 反射包feflection在mybatis路径如下: 源码解析 ... 
- Aspnet Zero中使用Windows service (Topshelf)来承载Quartz.net任务
			Aspnet Zero使用Windows service (Topshelf)来承载Quartz.net任务 网上有很多关于如何使用Topshelf创建ABP的Quartz windows服务,但很少 ... 
- python对端口进行扫描
			使用cocket模块配合多线程对端口进行扫描,后续功能正在思考ing. import socket from multiprocessing.dummy import Pool as ThreadPo ... 
- K8S(11)配置中心实战-单环境交付apollo三组件
			k8s配置中心实战-交付apollo三组件 目录 k8s配置中心实战-交付apollo三组件 1 apollo简单说明 1.1 apollo最简架构图: 1.2 apollo组件部署关系 2 为app ... 
- unity探索者之安卓微信登录,非第三方插件
			版权声明:本文为原创文章,转载请声明http://www.cnblogs.com/unityExplorer/p/7666348.html 之前写了两篇关于微信分享的博客,其实微信登录.分享.支付博主 ... 
- firewall几个常用命令
			systemctl status firewalld firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --r ... 
- Go | Go 语言打包静态文件以及如何与Gin一起使用Go-bindata
			系列文章目录 第一章 Go 语言打包静态文件以及如何与Gin一起使用Go-bindata 目录 系列文章目录 前言 一.go-bindata是什么? 二.使用步骤 1. 安装 2. 使用 3. 读取文 ... 
- Leecode统计子串个数(java)
			/** 获取一个字符串在另一个字符串中出现的次数.判断str2在str1中出现的次数 */ public class StringExer2 { public static void main(Str ... 
- Windows Server 2012 数据库定时备份
			为了数据的安全,我们在服务器上设置了每周备份一次,下面是具体步骤: 一.在文件客户端服务器创建db_backup.cmd的Windows命令脚本.输入以下内容(直接复制可能出错,请手动输入): @ec ... 
- 也谈基于Web的含工作流项目的一般开发流程
			项目包含的通用模块代码等我有时间一并剥离贡献出来(基于WebSocket的通知引擎,工作流整合模块,自定义表单,基于RBAC权限设计),最近太忙了,Web项目有一段时间没碰,有点生疏的感觉,主要在忙G ... 
