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..... ...
随机推荐
- 数据库 SQL 优化大总结之:百万级数据库优化方案
网上关于SQL优化的教程很多,但是比较杂乱.近日有空整理了一下,写出来跟大家分享一下,其中有错误和不足的地方,还请大家纠正补充. 这篇文章我花费了大量的时间查找资料.修改.排版,希望大家阅读之后,感觉 ...
- css技巧-案例
点击进入:http://herry.wuhairui.cn/cssSkill/main.html
- Prometheus监控学习笔记之初识PromQL
0x00 概述 Prometheus 提供了一种功能表达式语言 PromQL,允许用户实时选择和汇聚时间序列数据.表达式的结果可以在浏览器中显示为图形,也可以显示为表格数据,或者由外部系统通过 HTT ...
- P4381 [IOI2008]Island(基环树+单调队列优化dp)
P4381 [IOI2008]Island 题意:求图中所有基环树的直径和 我们对每棵基环树分别计算答案. 首先我们先bfs找环(dfs易爆栈) 蓝后我们处理直径 直径不在环上,就在环上某点的子树上 ...
- python简说(十九)操作redis
一.关系型数据库 mysql.oracle.sql server sql语句来操作数据,数据是存在磁盘上的 非关系型数据库.NOSQL,redis,memcache key = vaule 1.数据是 ...
- phpstorm 配置点右上角浏览器图标时用浏览器打开当前页面
文件>设置 只要这一步就可以这样了
- 20165211 2017-2018-2 《Java程序设计》课程总结
20165211 2017-2018-2 <Java程序设计>课程总结 一.每周作业及实验报告博客链接汇总 预备作业1:我期望的师生关系 预备作业2:学习基础和C语言调查 预备作业3:Li ...
- 前端 --- 2 css
一. CSS的几种引入方式 1.行内样式 2.内部样式 写在网页的<head></head>标签对的<style></style>标签对中 3.外部样式 ...
- tomcat部署maven web项目
tomcat上部署maven web项目的三种方法 1.将maven项目打成war包,然后放到tomcat容器中发布: 2.在IDE工具中部署tomcat,然后使用远程部署方式部署本地maven项目: ...
- Pytest 简明教程
pytest-learn 通过文章 Python 单元测试框架之 Pytest 剖解入门(第一篇) 学习 Pytest. 有很多的第三方插件可以自定义扩展,并且支持 Allure,生成可视化的测试报告 ...