2

In my mongodb I have this db Roles assigned to the user "master" in the "admin" db:

{ "_id" : "admin.master", "user" : "master", "db" : "admin", "roles" : [ { "role" : "dbOwner", "db" : "admin" }, { "role" : "dbOwner", "db" : "cars" } ] } 

Now if I try to access to mongo from the command line to the "cars" db with:

mongo 127.0.0.1/cars -u "master" -p

after entering the password I get this error:

connecting to: 127.0.0.1/cars 2014-11-22T12:23:27.377+0000 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210 exception: login failed

If instead I try to access mongo with:

mongo 127.0.0.1/admin -u "master" -p

As a result I can login.

Why I can not connect directly to the db "cars"?

Thanks

1 Answer 1

3

Try using the --authenticationDatabase option:

mongo localhost/cars --authenticationDatabase admin -u master -p 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.