检索现有数据库的名称时遇到问题:
<code>
        var connectionString = "mongodb://user:pw@localhost/admin";
        var client = new MongoClient(connectionString);
        var server = client.GetServer();
        var lst = server.GetDatabaseNames();
        lst.Dump(); -- this is in Linqpad
</code>
Linqpad 报告:
<code>
  Command 'listDatabases' failed: need to login (response: { "errmsg" : "need to      login", "ok" : 0.0 })            
在连接字符串中省略数据库名称时会发生同样的错误。在我的 c# 应用程序中使用时会发生同样的错误。
您能解释一下如何获得该列表吗?
好吧,与此同时,我查看了文档(我之前应该这样做,抱歉),发现我必须使用这个函数和一个提供管理员凭据的参数。
好的。但是错误消息令人困惑,应该是这样的:您必须提供管理员凭据............