How to export MongoDB collection to CSV

mongoexport command is used to export MongoDB collection into CSV or JSON format.

Syntax

Where

By default MongoDB connect to localhost port 27017

Example

Export mongodb collection to CSV file

In this case, we export fields “name,email,level” from “users” collection in database “main”. Result will be saved to file users.csv in current directory.

Back to MongoDB

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *