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 ...
随机推荐
- ANALYZE导致的阻塞问题分析
背景 问题描述 DBA同学收到qps大量下降的告警,qps从2w下降到1w,然后又自动恢复了. 基于Analysis Report信息,发现有很多 STATE:Waiting for table fl ...
- 二叉搜索树及java实现
二叉搜索树(Binary Search Tree) 二叉搜索树是二叉树的一种,是应用非常广泛的一种二叉树,英文简称为 BST 又被称为:二叉查找树.二叉排序树 任意一个节点的值都大于其左子树所有节 ...
- badger 一个高性能的LSM K/V store
原文:https://colobu.com/2017/10/11/badger-a-performant-k-v-store/ github地址:https://github.com/dgraph-i ...
- Python 抓包程序(pypcap)
#/usr/bin/env python #-*-coding:utf8-*- #抓包脚本 """ This script is used to Capture and ...
- 寻找猴王小游戏php代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- efcore技巧贴-也许有你不知道的使用技巧
前言 .net 环境近些年也算是稳步发展.在开发的过程中,与数据库打交道是必不可少的.早期的开发者都是DbHelper一撸到底,到现在的各种各样的ORM框架大行其道.孰优孰劣谁也说不清楚,文无第一武无 ...
- 模拟退火详解&P1433题解
前排提示:LZ是个菜比,有可能有讲的不对的地方,请在评论区指出qwq 0.基本思想 模拟退火其实没有那么高大上.说白了就是初始化一个"温度".每次随机乱选一个方案,如果比以前的方案 ...
- 用python导入20个G的json数据到Mysql数据库
整体思路参考资料:https://blog.csdn.net/layman2016/article/details/79252499 作业:有一个16个G的跟疫情相关的json新闻大数据(articl ...
- 新手oracle重启、监听
有一次遇到了记录下. #su到oracle用户下 [root@localhost ~]# su - oracle #重启数据库:[oracle@localhost ~]$ sqlplus /nolo ...
- python给excel文件加密码,并重新生成文件
需安装pywin32 pip install pywin32 直接上源码.简单几行就搞定 很多人学习python,不知道从何学起.很多人学习python,掌握了基本语法过后,不知道在哪里寻找案例上手. ...