MONGODB export JSON and CSV format data

Source: Internet
Author: User
Tags mongodump
Export to JSON:

$ mongoexport.exe-d testdb-c testcollection-o./test.json

Export to CSV:

If you are want to output CSV, you are specify the fields in the order you want them.

$ mongoexport.exe--csv-f _id,f1,f2,f3,f4,f5,f6,f7-d testdb-c testcollection-o./test.csv

If you have Chinese characters, opening the CSV file may be garbled, save it as a utf-8 format in Notepad.

When filtering data using the-Q query condition, pay attention to the ' (single quotes) on both sides

When the amount of data is very large, you can use--skip with--limit, limit the amount of data for a single file, easy for ordinary users to view

Alternatively, you can use the Mongodump command to back up your data:

$ mongodump-h 127.0.0.1:27017-d testdb-o./data

MONGODB export JSON and CSV format data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.