0

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.

Error screenshot

Solution:

Working with the below user roles Working user roles

HaBo
  • 13,999
  • 36
  • 114
  • 206
  • @whoeverDownvoted, please feel free to share what do you think is wrong in this question, so that I can correct my question. – HaBo May 06 '14 at 01:02
  • what happens if you connect to admin DB specifically (and not test)? Add the word admin to the end of your mongo command line. – Asya Kamsky May 06 '14 at 02:16

2 Answers2

2

try this

mongo -u yourUser -p yourPwd --authenticationDatabase admin
0

use

mongo --port 27017 -u username -p pas

dhanunjay
  • 1
  • 3