MongoDB Atlas身份验证在Python上失败

编程入门 行业动态 更新时间:2024-10-28 11:33:13
本文介绍了MongoDB Atlas身份验证在Python上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已将此Python应用程序部署在Heroku上,并且希望它连接到MongoDB Atlas集群.我使用我的字符串连接到集群,但是由于某些原因,我不断得到raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: bad auth Authentication failed.,我检查了两次,并且用户名和密码均正确.知道为什么会这样吗?

I have deployed this Python app on Heroku and i want it to connect to a MongoDB Atlas cluster. I used my string to connect to the cluster, but for some reason i keep getting raise OperationFailure(msg % errmsg, code, response) pymongo.errors.OperationFailure: bad auth Authentication failed. I checked twice and both the user and the password are correct. Any idea on why this is happening?

from pymongo import MongoClient import time import random import time import datetime client = MongoClient('mongodb+srv://USER:<MYPASSWORD>@test-2liju.mongodb/test?retryWrites=true') db = client.one mycol = client["tst"] while True: test = int(random.randrange(-99999990,90000000,1)) dic = {"num": test} result = db.tst.insert_one(dic) print(test) time.sleep(5)

推荐答案

愚蠢的错误,我必须键入MYPASSWORD而不是<MYPASSWORD>,而没有<>

Stupid error, i had to type MYPASSWORD instead of <MYPASSWORD>, without the <>

更多推荐

MongoDB Atlas身份验证在Python上失败

本文发布于:2023-10-13 00:40:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1486319.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   MongoDB   Atlas   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!