2

I use mongojs to connect my Node.JS to MongoDB.

When I do mongo easymail -u admin -p PWD --authenticationDatabase=admin from bash, everything goes right.

But : mongodb://admin:PWD@localhost:27017/easymail?auto_reconnect=true&authSource=admin give me

{ [MongoError: auth failed] name: 'MongoError', message: 'auth failed', ok: 0, errmsg: 'auth failed', code: 18 }

Where is the problem ?

Thank you!

izanagi_1995
  • 94
  • 1
  • 8

1 Answers1

0

You didn't include your entire command, but it looks like it could be an issues with escaping. Try placing your connections string in double quotes like this:

mongo "mongodb://admin:PWD@localhost:27017/easymail?auto_reconnect=true&authSource=admin"
Martin
  • 5,119
  • 3
  • 18
  • 16
  • Hello, I can't see any double quote... I tried your command : `Error: More than one ':' detected.` – izanagi_1995 Sep 29 '15 at 08:34
  • I minified your command to `mongo localhost:27017/easymail?authSource=admin -u admin -p PWD` to make it working. Same problem 'Auth Failed'. But when I do `mongo localhost:27017/admin -u admin -p PWD` everything is ok... – izanagi_1995 Sep 29 '15 at 08:41
  • 1
    It seems that mongoDB ignore the authSource argument from shell or node – izanagi_1995 Sep 29 '15 at 09:11