mongodb 非 admin 庫 認證登陸失敗 原因(百度好多都 是渣)db.addUser() 請走開。

來源:互聯網
上載者:User

標籤:

首先先曬一下log 日誌錯誤資訊

2016-07-13T22:19:43.667+0800 I ACCESS   [conn4]  authenticate db: finddemo { authenticate: 1, nonce: "xxx", user: "user1", key: "xxx" }2016-07-13T22:19:43.668+0800 I ACCESS   [conn4] Failed to authenticate [email protected]ddemo with mechanism MONGODB-CR: AuthenticationFailed: UserNotFound: Could not find user [email protected]2016-07-13T22:20:12.555+0800 I ACCESS   [conn2] SCRAM-SHA-1 authentication failed for user1 on finddemo from client 127.0.0.1 ; UserNotFound: Could not find user [email protected]2016-07-13T22:20:17.127+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:56103 #5 (4 connections now open)2016-07-13T22:20:17.127+0800 I ACCESS   [conn5]  authenticate db: admin { authenticate: 1, nonce: "xxx", user: "root", key: "xxx" }2016-07-13T22:20:17.146+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:56104 #6 (5 connections now open)2016-07-13T22:20:17.146+0800 I ACCESS   [conn6]  authenticate db: admin { authenticate: 1, nonce: "xxx", user: "root", key: "xxx" }

著重看一下 這個報錯資訊,

SCRAM-SHA-1 authentication failed for user1 on finddemo

這是什麼鳥?   

mongodb加入了SCRAM-SHA-1校正方式,需要第三方工具配合進行驗證,下面給出具體解決辦法: 

首先關閉認證,修改system.version文檔裡面的authSchema版本為3,初始安裝時候應該是5,命令列如下: 

> use admin switched to db admin >  var schema = db.system.version.findOne({"_id" : "authSchema"}) > schema.currentVersion = 3 3 > db.system.version.save(schema) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })  

 

 

下面是擷取到的使用者的相關資訊

{ "_id" : "admin.root", "user" : "root", "db" : "admin", "credentials" : { "MONGODB-CR" : "97a156792bd180dc82cec9a56d838991" }, "roles" : [ { "role" : "__system", "db" : "admin" } ] }{ "_id" : "finddemo.finddemo", "user" : "finddemo", "db" : "finddemo", "credentials" : { "MONGODB-CR" : "4b8dce39de95d553473c1998f43aa165" }, "roles" : [ { "role" : "dbOwner", "db" : "finddemo" } ] }

 

重新串連,成功。

可以查看一下連結介紹:

https://docs.mongodb.com/master/release-notes/3.0-scram/

還有國外友人的回答:(越來越鄙視百度黨)

http://stackoverflow.com/questions/29006887/mongodb-cr-authentication-failed

  

mongodb 非 admin 庫 認證登陸失敗 原因(百度好多都 是渣)db.addUser() 請走開。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.