mongodbpasswordsnodejitsu

MongoDB CLI authentication failed on mongoHQ hosted on Nodejitsu


I have an app on Nodejitsu with a MongoHQ database that is working. Now I wish to see and manage my DB from my terminal. Here is the code I write:

mongo troup.mongohq.com:10014/database -u <dbuser> -p <dbpassword>

The problem is I don't know whats my username and password. All I get from Nodejitsu is the MongoHQ username and Password but thats not correct.

Basically - How do I get my username and password for the DB - as stated in this question -

Unable to connect to MongoLab "auth fails" error

Currently I am getting -

Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:228

Thank you very much


Solution

  • By default I believe Mongo tries to connect to the admin database. You should ensure that the user has the correct permissions usually readWrite. If that user is responsible only for a specific database consider doing the following from the CLI:

     mongo troup.mongohq.com:10014/database -u <dbuser> -p <dbpassword>   --authenticationDatabase <databasename>
    

    If however that user will be responsible for multiple databases. You should update the privileges for that user. More at the MongoDb docs Create the system user administrator and privileges