MongoDB - Exporting Data using mongoexport

Let us also understand how to export the data using mongoexport.

  • Developers can exchange the export dumps and import to databases in other MongoDB servers or even other Relational Databases.
  • It takes several control arguments and we can get those using mongoexport --help
    • -h for host
    • --port for port
    • --db for the name of the database
    • --collection for the name of the collection
    • --type for file format (csv or json)
    • --fields to specify fields
    • --out to specify the path of the file
    • --noHeaderLine if we do not want to get field names as a header in case of CSV files.
  • Output data can be either delimited text format or JSON

I get an error when i try to use mongoexport command.

bash: mongoexport: command not found…