Mongexport producing 0 records for a collection (from Atlas)

Hi, I have a Atlas service and created a test database (TestDB). Created a cluster with 2 documents in it. Nothing fancy. Trying to export the data from this cluster using mongoexport on my macbookpro. I am getting the below message:

./mongoexport --uri mongodb+srv://Test:@/TestDB --collection=DataTypeSet --out=DTT.json
2020-09-15T12:34:11.497-0400 connected to: mongodb+srv://[REDACTED]@
2020-09-15T12:34:11.540-0400 exported 0 records

I don’t think its a permission issue. Been able to use mongodump to dump the cluster fully. Wanted to get a proper json export. Any ideas? Thanks much !.

I have seen this happen when there is a mismatch between the mongoexport client and the server. To double check try doing an export with Compass which has an export function built in.

What version of mongoexport and what version of the server are you running?

Here is how to get the mongoexport version:

JD10Gen:~ jdrumgoole$ mongoexport --version
mongoexport version: r4.2.7
git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
Go version: go1.12.17
   os: darwin
   arch: amd64
   compiler: gc
JD10Gen:~ jdrumgoole$

Hi Joe:

Here is the outputput from Mongoexport --version

./mongoexport --version
mongoexport version: 100.1.1
git version: 8bca136c2a0e0daa3947df31c0624c5615f9aa02
Go version: go1.12.17
os: darwin
arch: amd64
compiler: gc

I have tried to use all the latest versions basically. For MongoDB, I am using the Atlas service. Do you think this could be an issue with compatibility between Mongo tools and Atlas Service? What version of tools/CLI would you recommend for working with Atlas.

Thanks much for your guidance.

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&" --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.


1 Like

Hi, The version is 4.2 and its a MO instance. So I cannot upgrade to a different version it seems. Maybe I will have to delete the current cluster and create another free instance with version 4.2.9 or higher. I created this just recently. Didn’t realize its not the latest version.

Thanks for pointing that out.

M0, M2 and M5 instances are shared instances so you cannot upgrade their versions yourself.

Deleting and recreating an M0 instance won’t upgrade it to a higher version, you will just be linked again to the same shared cluster. They will be upgraded to 4.4 automatically in a near future by the Atlas team.

I tested mongoexport 100.1.1 with

  • an M0 instance - currently 4.2.9
  • an M10 instance in 4.4.0

And mongoexport worked with both. Please double check your command line and your user & IP address as I explained above. It should work for you too.


I will try this tonite and keep you posted. Thanks much !.

Hi, Wanted to confirm that using a MongoDB version 4.4 fixed the problem and I see that 1 record is getting exported. Thanks for the pointer about version mismatch between the utilities and the MongoDB version. I will mark this thread as closed.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.