from pymongo import MongoClient host = '127.0.0.1' client = MongoClient(host, ) #连接mydb数据库,账号密码认证 db = client.admin # 先连接系统默认数据库admin # 下面一条更改是关键,我竟然尝试成功了,不知道为啥,先记录下踩的坑吧 db.authenticate(",mechanism='SCRAM-SHA-1') # 让admin数据库去认证密码登录,好吧,既然成功了, my_db =…