python - OperationFailure:尽管凭据正确,但在插入 MongoDB 集合时身份验证失败
问题描述
我有一个 MongoDB 数据库,我尝试从一个协作笔记本中添加一些东西:
client = pymongo.MongoClient("mongodb+srv://test:<mypassjeje>@<unique identifier>.mongodb.net/<dbnamejojo>?retryWrites=true&w=majority")
db = client.test
fragrance = db.fragrance_db
我用测试用户的密码和默认情况下连接将使用的数据库的名称替换。
Pero cuando intento insertar una cosa:
fragrance.insert_one(perfume)
它返回:
---------------------------------------------------------------------------
OperationFailure Traceback (most recent call last)
<ipython-input-48-d831294ab74e> in <module>()
46 count += 1
47
---> 48 __main__()
19 frames
/usr/local/lib/python3.6/dist-packages/pymongo/helpers.py in _check_command_response(response, max_wire_version, msg, allowable_errors, parse_write_concern_error)
166 msg = msg or "%s"
167 raise OperationFailure(msg % errmsg, code, response,
--> 168 max_wire_version)
169
170
OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}
我也在最后尝试&authSource=admin
:
client = pymongo.MongoClient("mongodb+srv://test:<mypassjeje>@<unique identifier>.mongodb.net/<dbnamejojo>?retryWrites=true&w=majority&authSource=admin")
但它返回相同的错误:
OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}
解决方案
推荐阅读
- php - 检查空值 PHP 更短的代码
- python - python rfid evdev 和树莓派 GPIO 输入
- deep-learning - 我正在实现一个 GAN 网络,但我对如何将它们组合成一个实体感到困惑?
- square-connect - 是否可以使用 Square 将应用开发者帐户的客户与商家帐户共享
- excel - 在 Excel 中创建具有 3 个标准的随机组
- encoding - 01 代表 1 和 10 代表 0 的二进制编码的名称是什么
- javascript - 支持高分辨率显示,同时允许缩放
- qt - QT QTableWidget,如何在项目不可编辑时选择文本
- c++ - 在 C++ 中使用字符串成员作为索引更新自定义结构的最佳方法
- android - 不显示视频,只有在 react-native-video 中播放真正的 android 设备时才会发出声音