“错误的身份验证失败。”在python中连接到mongodb地图集时出错

时间:2019-06-05 18:45:53

标签: python mongodb atlas

我正在尝试使用以下代码使用python连接到mongodb地图集:

import pymongo
myclient = pymongo.MongoClient("mongodb+srv://username:p%40ssword@cluster0-t9lf6.mongodb.net/test?retryWrites=true&w=majority")
mydb = myclient["test"]
mycol = mydb["somecol"]

dblist = myclient.list_database_names() #trial-1

x = mycol.find_one() #trail-2

我在Trail-1和Trail-2上都遇到错误:

OperationFailure: bad auth Authentication failed.

假设我的用户名是 username ,密码是 p%40ssword ,其中@替换为%40。 我检查了我的凭据,它们是正确的。但我仍然收到此错误。该怎么办?

0 个答案:

没有答案
相关问题