无法连接到mongoDB

时间:2014-12-23 18:47:36

标签: mongodb appharbor

尝试使用MongoLab AddOn连接到mongoDB,我收到以下错误:

{ "$err" : "not authorized for query on myAppDB.Users", "code" : 13 }

当我运行以下代码时:

private string connectionString = "mongodb://appharbor_93126661-e8b7-4986-958c-74e4ed8401e6:qj0boq192osh10rXXXXXXXX@ds027521.mongolab.com:27521/appharbor_93126661-e8b7-4986-958c-74e4ed8401e6";
private string dbName = "myAppDB";
private string userCollectionName = "Users";

private MongoCollection<User> GetUsersCollection()
{
      MongoUrl url = new MongoUrl(connectionString);
      MongoClient client = new MongoClient(url);
      mongoServer = client.GetServer();
      MongoDatabase database = mongoServer.GetDatabase(dbName);
      MongoCollection<User> userCollection = database.GetCollection<User>(userCollectionName);
      return userCollection;
}

我尝试从运行命令的shell连接:

mongo ds027521.mongolab.com:27521/appharbor_93126661-e8b7-4986-958c-74e4ed8401e6 -u appharbor_93126661-e8b7-4986-958c-74e4ed8401e6 -p qj0boq192osh10rXXXXXXXX

但还没有设法连接。

如果有人遇到类似的问题或知道导致问题的原因,我会非常感谢任何解决问题的建议。

0 个答案:

没有答案