Mongexport producing 0 records for a collection (from Atlas)

Looks like you have the latest version of the tools @Prekesh_Nduri.
Is your MongoDB cluster in 4.4.0? I have also tried with a Free cluster in 4.2.9 and it’s working just fine with mongoexport 100.1.1. If your cluster is in an older version, I would update to make sure version numbers are aligned or use the appropriate mongoexport version.

To avoid doing a mistake in the command line, please retrieve the command line from the Command Line Tools tab in Atlas:

Then scroll down and you will find this section:

Copy the mongoexport command line and make sure to replace all the placeholders with the correct values.

In the end, my command line looks like this:

mongoexport --uri "mongodb+srv://max:MySafe&ComplexPassword@free.ne23r.mongodb.net/test" --collection col --type json --out col.json

Note here that I have added double quotes around the URI to avoid an issue if the password contains a “&” for example or another special character that would break the command line logic.

Also, make sure the user you are using has enough privileges on this collection in the Security > Database Access menu and make sure your current IP address is in the IP Access List in the Security > Network Access menu.

Cheers,
Maxime.

1 Like