Reputation: 1329
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.
Upvotes: 16
Views: 21454
Reputation: 2217
For some reason no matter what i did, mongoexport
or mongodump
utilities didnt work for me as the default user, even after resetting my password, whilst I was, however, able to connect as default user to the mongo shell.
But the solution for me was from the settings page of your database on mlabs.com you can create more users, and i was then able to connect to these utilities with the new user. You can probably create new users in the shell too, but id just use the online tool.
mongoexport -h <serverURL:port> -d <database> -c <collection> -u <newuser> -p <newpassword> -o collection.json
Upvotes: 1
Reputation: 141
Adding the additional parameter didn't work for me.
I contacted mLab support and was told the shell and/or driver I was connecting with was not compatible with MongoDB 3.0.x, the version that my database was running.
I installed 3.0.10 and was then able to connect successfully.
Upvotes: 14
Reputation: 1329
Worked perfect with that additional parameter --authenticationDatabase admin
.
Upvotes: 29