I have this below user created in MongoDB
/* 1 */
{
"_id" : ObjectId("5368247553e1d8650fdee0d1"),
"user" : "userName",
"pwd" : "3d8540469xxxxxxxxxxxxxxx28fbf8b76",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
Now I am trying to connect to my remote MongoDB instance
>mongo --host 10.0.0.1 --port 27017 --username username --password password
I get bellow error
errmsg: auth failed
code: 18
exception: login failed
I am not sure what is wrong. If i disable authorization in my config file and restart my replica sets instances, I can connect correctly.
Solution:
Working with the below user roles