MongoDB - cannot get data exported using mongoexport due to auth error

I have a Mongo DB database and am trying to export a couple of "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 } 

I don’t know what is wrong here.

+6
source share
4 answers

Worked with this additional parameter --authenticationDatabase admin .

+4
source

Adding an additional parameter did not help me.

I contacted mLab support and said that the shell and / or driver I was connecting to were not compatible with MongoDB 3.0.x, a version of my database.

I installed 3.0.10 and was able to successfully connect.

+13
source

For some reason, no matter what I did, the mongoexport or mongodump did not work for me as the default user, even after resetting the password, although I could, however, connect as the default user to the mongo shell.

But the solution for me was on the settings page of your database on mlabs.com, you can create more users, and then I was able to connect to these utilities with a new user. Perhaps you can also create new users in the shell, but id just uses an online tool.

 mongoexport -h <serverURL:port> -d <database> -c <collection> -u <newuser> -p <newpassword> -o collection.json 
0
source

Adding a new user / password to mlabs.com settings worked for me.

0
source

Source: https://habr.com/ru/post/983671/


All Articles