Larry Lu
Larry Lu

Reputation: 1661

Authentication failed when using mongo to connect mlab.com

I have a account on mlab.com.
mlab-hosted deployment is running MongoDB 3.0.
I install MongoDB 3.0.10 in my computer.
I connect to mlab.com using this command:

mongo ds019480.mlab.com:<port>/<database> -u <username> -p <password>

But I get error message:

MongoDB shell version: 3.0.10-4-gbd56c2f
connecting to: ds019480.mlab.com:19480/larry-database
2016-04-08T08:45:27.101+0800 E QUERY    Error: 18 Authentication failed.
    at DB._authOrThrow (src/mongo/shell/db.js:1271:32)
    at (auth):6:8
    at (auth):7:2 at src/mongo/shell/db.js:1271
exception: login failed

How do I connect to mlab.com successfully?

Upvotes: 2

Views: 2508

Answers (2)

Ryan Alexander
Ryan Alexander

Reputation: 569

Aside from the common mistake of using your Heroku or mLabs username/password, another one may be using "double quotes".

mongo ds012345.mlab.com:<port>/<database> -u "username" -p "password"
exception: login failed
mongo ds012345.mlab.com:<port>/<database> -u 'username' -p 'password'
rs-ds012345:PRIMARY> 

What’s the Difference Between Single and Double Quotes in the Bash Shell?

Conclusion: All characters within single quotes are interpreted as a string character.

Upvotes: 0

dannyde
dannyde

Reputation: 122

remove any signs/symbols from your password. in particular '!' and '$'.

Upvotes: 3

Related Questions