![](/img/trans.png)
[英]Mongodb + Atlas: 'bad auth Authentication failed.', code: 8000,
[英]MongoDB atlas through mongo shell: “Error: bad auth : Authentication failed.” what could possibly cause this Authentication failure?
我在通過 mongo shell 連接到 MongoDB 圖集時遇到了問題,即使我已經做對了所有事情並且三重檢查了數據用戶名和密碼,將我的 IP 包含在白名單中,將數據庫名稱更改為 test,並嘗試在同一個中添加 --password線
`$ mongo "mongodb+srv://cluster******.mongodb.net/test" --username admin --password admin MongoDB shell version v4.4.6 連接到:mongodb://cluster0-shard-00 -00.4d5jd.mongodb.net:27017,cluster0-shard-00-01.4d5jd.mongodb.net:27017,cluster0-shard-00-02.4d5jd.mongodb.net:27017/test?lcompressors=disabledName&gsssapi
*** 您未能連接到 MongoDB Atlas 集群。 請確保您的 IP 白名單允許來自您網絡的連接。
錯誤:身份驗證錯誤:身份驗證失敗。 :connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6 異常:連接失敗退出代碼 1`
MongoDB Atlas 在 admin 數據庫中創建所有用戶。
您嘗試的輸出並不表明它正在使用 admin 數據庫進行身份驗證,因此您可能需要使用--authenticationDatabase
命令行選項,或在 URL 中包含authSource=
,即以下之一:
mongo "mongodb+srv://cluster******.mongodb.net/test" --username admin --password admin --authenticationDatabase admin
要么
mongo "mongodb+srv://cluster******.mongodb.net/test?authSource=admin" --username admin --password admin
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.