pymongo.errors.OperationFailure: Authentication failed.
mongoDB有不同的认证机制,3.0版本以后采用的是'MONGODB-CR', 之前的版本采用的是'MONGODB-CR'。
所以,以我的版本情况,显然应该用'SCRAM-SHA-1'
from pymongo import MongoClient
host = '127.0.0.1'
client = MongoClient(host, )
#连接mydb数据库,账号密码认证
db = client.admin # 先连接系统默认数据库admin
# 下面一条更改是关键,我竟然尝试成功了,不知道为啥,先记录下踩的坑吧
db.authenticate("root", "",mechanism='SCRAM-SHA-1') # 让admin数据库去认证密码登录,好吧,既然成功了,
my_db = client.mydb # 再连接自己的数据库mydb
collection = my_db.myset # myset集合,同上解释
collection.insert({"name":"zhangsan","age":}) # 插入一条数据,如果没出错那么说明连接成功
for i in collection.find():
print(i)
pymongo.errors.OperationFailure: Authentication failed.的更多相关文章
- 使用pymongo连接mongodb时报错:pymongo.errors.OperationFailure: not authorized
连接本机或局域网部署的mongodb时可以用以下方法: from urllib import parse from pymongo import MongoClient host = '*.*.*.* ...
- smtplib.SMTPAuthenticationError: (535, b'Error: authentication failed')解决办法
raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'Error: authentica ...
- javaMail使用163邮箱报535 Error: authentication failed
javaMail使用网易163邮箱或者是126或者是网易其他邮箱报535 Error: authentication failed javax.mail.AuthenticationFailedExc ...
- github提交失败并报错java.io.IOException: Authentication failed:
一.概述 我最近在写一个android的项目. 软件:android studio.Android studio VCS integration(插件) Android studio VCS inte ...
- IndexOf("authentication failed") > -1
if (e.Value.Error.Message.IndexOf("authentication failed") > -1) { strFailMessag ...
- (转载)postgresql navicat 客户端连接验证失败解决方法:password authentication failed for user
命令:su - postgres CREATE USER foo WITH PASSWORD 'secret'; ==================== 1.2个配置修改 postgresql.co ...
- pgadmin3 新建服务器出现错误 Peer authentication failed for user "postgres" 的解决办法
转自:http://blog.csdn.net/tingyuanss/article/details/43763899 用pgadmin3 新建服务器出现错误 Peer authentication ...
- MongoDB3.4安装配置以及与Robomongo1.1的连接——解决Authentication Failed导致的不能连接问题
本文环境:win10(64)+MongoDB(3.4.5)+Robomongo(1.1) 目录: MongoDB的安装 MongoDB的配置 Robomongo的安装以及与MongoDB的连接 一些新 ...
- fatal: Authentication failed for “someurl”
一.前言 我们在公司做项目,很多时候会遇到这个问题:Git failed with a fatal error. Authentication failed for ‘ http// xxx..... ...
随机推荐
- Charles 从入门到精通 --转
文章目录 1. 目录及更新说明 2. Charles 限时优惠 3. 简介 4. 安装 Charles 5. 将 Charles 设置成系统代理 6. Charles 主界面介绍 7. 过滤网络请求 ...
- Java 持久化操作之 --XML
摘自:http://www.cnblogs.com/lsy131479/p/8728767.html 1)有关XML简介 XML(EXtensible Markup Language)可扩展标记语言 ...
- IP代理
import requests # 定义爬取url地址 base_url = 'https://www.baidu.com/' # 定义代理IP地址 proxies = {'http':'http:/ ...
- Oracle 手动建库
Oracle在创建实例的时候,多数采用的是dbca的形式..其实手动建库可以提供更大的自由发挥的空间,根据情况进行定制 登录Oracle用户 指定SID(Instance Identifier) ex ...
- python之路-day1-while循环
while Thue: (条件为真无限循环) break(跳出循环) 猜年龄: #Author:zwwage_of_jay = 40count = 0while count < 3: gues ...
- 牛客练习赛24题解(搜索,DP)
A题,C题不讲,基础题(但是我要抨击一下这次比赛,卡cin,cout,卡的太狠了,根本就不让过的那种,QAQ) 链接:https://www.nowcoder.com/acm/contest/157/ ...
- [翻译]使用VH和VW实现真正的流体排版
前言 不像响应式布局,通过media query,设置几个变化点来适配,流体排版通过调整大小,适配所有设备宽度.这个方法可以使我们开发的网页,在几乎所有屏幕尺寸上都可以使用.但出于一些原因,它的使用率 ...
- CodeForces 867B Save the problem
B. Save the problem! http://codeforces.com/contest/867/problem/B time limit per test 2 seconds memor ...
- POJ 3041 Asteroids(最小点覆盖)题解
题意:n*n的网格中有k个点,开一枪能摧毁一行或一列的所有点,问最少开几枪 思路:我们把网格看成两个集合,行集合和列集合,如果有点x,y那么就连接x->y,所以我们只要做最小点覆盖就好了. 参考 ...
- 【做题】atc_cf17-final_E - Combination Lock——巧妙转化及图论
题意:给出一个由26个小写字母组成的字符串,可以任意地进行若干个操作,每次操作是让指定区间内的字母变为下一个字母(z变成a).问是否存在方案使得这个字符串变为回文串. 一开始的想法是构造len/2条模 ...