Mongoexport in MongoDB

Mongoexport is the MongoDB command used to take the backup of collections (tables) in JSON or CSV format. This command should be executed from the command prompt not from the MongoDB clients.


1) Mongoexport --db databasename --collection collection --out filenametosave.json

2) mongoexport --host --port Portnumber --username user --password pass --collection collectionname --db databasename --out filenametosave.json


Mongoexport –db test –collection store --out store.json

Mongoexport –db test –collection store --out “D:\ backup\store.csv”

First example will save the file in the root directory and second will save in specified directory.