1

I have a problem that I can not connect to MongoDB from external Tootls that is not via MongoShell or my webapp using Spring Data MongoDB abstraction.

I've successfully created a user for 'mydb' database on MongoDB And I can connect to MongoDb on my localhost using the command

$ mongo mydb -u alex -p 12345678 --host localhost --port 27017

MongoDB shell version: 3.0.1
connecting to: localhost:27017/mydb
> show users
{
    "_id" : "mydb.alex",
    "user" : "alex",
    "db" : "mydb",
    "roles" : [
        {
            "role" : "readWrite",
            "db" : "mydb"
        }
    ]
}

Now I can insert Collections and query and everything looks smooth. I can connect with Spring Data MongoDB abstraction from my web-app as well.

When I now try to connect using Robomongo application or Intellij Plugin for MongoDB using correct host, port, db, username and password I get an authorization error

From Intellij

Error when collecting Mongo databases: { "serverUsed" : "localhost:27017" , "ok" : 0.0 , "errmsg" : "auth failed" , "code" : 18}

From Robomongo

2015-04-02 16:00:30: Connecting to localhost:27017...
2015-04-02 16:00:30: connect failed
2015-04-02 16:00:30: Unable to authorize

I'd like to use some GUI client to have better visualisation and CRUD operation support but at the moment I can't manage to connect to MongoDB

Do you know what could the reason for this?

spike07
  • 809
  • 2
  • 12
  • 21
  • What version of MongoDB are you using? 3.0? 3.0 has improved security but it require newer driver versions. Many tools have not been updated yet to support 3.0. I know specifically that Robomongo has not been, for example. – wdberkeley Apr 02 '15 at 18:37
  • Thanks for the comment. Yes, I'm using MongoDB 3.0. In fact I was thinking it's something related to 3.0 version as I saw the auth mechanism is changed to SCRAM-SHA-1. I think I saw somewhere how to set mongoDB to be config on the old auth mechanism. Maybe that would make the tools work again. I will give a try – spike07 Apr 02 '15 at 19:38
  • With GUI client, everything is fine but user creation is not. Currently almost GUI clients do not have field `credentials` which contains user's password encrypted by MONGODB-CR or SCRAM-SHA-1 that required by MongoDB authentication. So you should you MongoDB command to create user, more infomation follow this [Create Administrative User with Roles](https://docs.mongodb.com/manual/reference/method/db.createUser/#create-administrative-user-with-roles) – Trung Le Nguyen Nhat Jun 29 '16 at 09:25

1 Answers1

0

I had the same issue and in the mongoDb logs I see:

failed to authenticate xxx@yyyy with mechanism MONGODB-CR: AuthenticationFailed MONGODB-CR credentials missing in the user document

I believe this post MongoDB-CR Authentication failed explains what to do to set back the old authentication. You will need to delete existing users and add new ones again.

Community
  • 1
  • 1
Rob Baily
  • 2,770
  • 17
  • 26