MongoDB - can't get data exported with mongoexport due to auth failed

L.D picture L.D · Mar 11, 2015 · Viewed 16.7k times · Source

I have a Mongo DB database and I trying to export couple "records" from one of the collections present in this database. Here is the command I am trying to use and the error I am getting:

mongoexport --collection my_collection --out my_collection.json --limit 10 --db my_db --username mongoadmin --password secret --host localhost

connected to: localhost
assertion: 18 { ok: 0.0, errmsg: "auth failed", code: 18 }

Don't know what is wrong here.

Answer

L.D picture L.D · Mar 16, 2015

Worked perfect with that additional parameter --authenticationDatabase admin.