2016-11-15 286 views
3

我試圖與下面的連接字符串authSource在mongo數據庫url中意味着什麼?

var Mongo_url = 'mongodb://MyUSer:[email protected]:27017/chatme?authSource=admin'; 

我得到錯誤的

assertionError: null == { [MongoError: Authentication failed.] 
name: 'MongoError', 
message: 'Authentication failed.', 
ok: 0, 
code: 18, 

任何人都可以請清除此「authSource = admin」的東西給我連接到我的蒙戈數據庫。

回答

2

這是具有帶用戶證書的集合的數據庫的名稱。

https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options

這就是用戶名和密碼都設置。

+0

我有我的用戶在system.users集合。所以根據你的'authSource = admin'應該用authSource = users替換。對?? –

+0

不,這是數據庫的名稱,而不是集合。它默認爲您嘗試連接的數據庫。它沒有參數工作嗎? – Thilo

+0

是的,它沒有參數。我現在明白了。謝謝 –