Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb: Auth mechanism not specified

Tags:

mongodb

I followed the instructions here for setting up users...

Then from another machine I do:

mongo -u admin -p adminpassword host/collection

The response I get is:

MongoDB shell version: 2.6.10 connecting to: host/collection 2019-07-12T06:20:36.336+0000 Error: 2 { ok: 0.0, errmsg: "Auth mechanism not specified", code: 2, codeName: "BadValue" } at src/mongo/shell/db.js:1287 exception: login failed

Now, I suppose this is an issue with different versions but what I'm really after is to remote connect from a node script and that's failing as well but the only message is: "MongoError: Authentication failed."

Does anyone know a solution?

like image 791
pguardiario Avatar asked Nov 26 '25 18:11

pguardiario


1 Answers

Ran into the same issue when using an old Mongo shell version (2.x/3.x) with a 4.0+ server. Upgrading the Mongo shell to 4.0.6+ seems to have resolved the issue.

My guess is the protocol to authenticate and specifying auth mechanisms has changed in newer server versions.

like image 166
fryingcan Avatar answered Dec 01 '25 16:12

fryingcan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!