Search code examples
mongodbmongoexport

mongoexport exports 0 records


ran this command, and 0 records were exported. [changed the db and collection names for privacy]. doubled checked the syntax.

 mongoexport --db db_name --collection collection_name --out collection_name_delete.json --verbose
    2015-10-15T08:18:02.825+0000    connected to: localhost
    2015-10-15T08:18:02.825+0000    exported 0 records
    root@sever_name:/mnt/data# mongo db_name
    MongoDB shell version: 3.0.0
    connecting to: db_name
    DBReplicaSet:PRIMARY> db.dip_acon_research_finals.count()
    1597113

Solution

  • You have a replica set and not a stand alone setup. You must use correct set of switches for connecting to the replica set. Try again with --host and --port arguments. For more reference see https://docs.mongodb.org/manual/reference/program/mongoexport/