Newly created MongoLabs database not allowed

I am trying to start with MongoLab. Using the mongo shell, it seems that I cannot authenticate any database I created, even with a completely new account and database.

I created a MongoLab user with the same username and password as my database user, so I'm sure there are no errors in the username and password.

# connect to mongod v2.4.3 using 2.4.3 client: # imac ~/Desktop/mongodb-osx-x86_64-2.4.3/bin$ ./mongo ds059557.mongolab.com:59557/cachv -u redacted -p redacted MongoDB shell version: 2.4.3 connecting to: ds059557.mongolab.com:59557/cachv > use mydb switched to db mydb > db.things.insert({f:1}) not authorized for insert on mydb.things 

or

 # connect to mongod v2.2.4-rc0 using 2.4.3 client: # imac ~/Desktop/mongodb-osx-x86_64-2.4.3/bin$ ./mongo dbh83.mongolab.com:27837/cachv2 -u redacted -p redacted MongoDB shell version: 2.4.3 connecting to: dbh83.mongolab.com:27837/cachv2 Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user Error while trying to show server startup warnings: need to login > use mydb switched to db mydb > db.things.insert({f:1}) Sat Apr 27 05:46:32.456 JavaScript execution failed: getlasterror failed: { "errmsg" : "need to login", "ok" : 0 } at src/mongo/shell/db.js:L698 > db.auth('redacted','redacted') Error: 18 { errmsg: "auth fails", ok: 0.0 } 0 

after the second attempt:

 imac ~/Desktop/mongodb-osx-x86_64-2.4.3/bin$ ./mongo dbh83.mongolab.com:27837/cachv2 -u redacted -p redacted MongoDB shell version: 2.4.3 connecting to: dbh83.mongolab.com:27837/cachv2 Error while trying to show server startup warnings: need to login 

Finally, I downloaded the older client 2.2.4, but still no luck:

 # connect to mongod v2.2.4-rc0 using 2.2.4 client: # mac ~/Desktop/mongodb-osx-x86_64-2.2.4/bin$ ./mongo dbh83.mongolab.com:27837/cachv2 -u redacted -p redacted MongoDB shell version: 2.2.4 connecting to: dbh83.mongolab.com:27837/cachv2 > use mydb switched to db mydb > db.things.insert({'g':1}) Sat Apr 27 06:00:30 uncaught exception: getlasterror failed: { "errmsg" : "need to login", "ok" : 0 } > db.auth('redacted','redacted') Error: { errmsg: "auth fails", ok: 0.0 } 0 > db.things.insert({'g':1}) Sat Apr 27 06:00:47 uncaught exception: getlasterror failed: { "errmsg" : "need to login", "ok" : 0 

Are there any additional ports that need to be opened at the end?

Can anyone help?

Thanks!

Darren

+4
source share
1 answer

Ok! I fixed it.

For some reason, -u and -p did not work for me, and it seems that the db.auth () call should be called as the first command in the shell after connecting.

Also, for pymongo, it seems that the username / password processed from the server line didn't work, and instead I had to call db.authenticate (user, password).

+9
source

All Articles