Mongodb Study Notes 07: mongodb Study Notes

Source: Internet
Author: User
Tags mongodump mongorestore

Mongodb Study Notes 07: mongodb Study Notes

  • Export export in json or csv format
  • Using import to import json or csv
  • Mongodump exports binary bson structure data and index information
  • Mongorestore imports binary files

Mongoexport

-H host -- port number-u user name-p password-d database name-c table name-f field1, field ..... export field-q query condition-o export file name -- csv is equivalent to -- type = csv export csv format, you must specify-f export field to export csv

Example: export the _ id and username of my_id <200 in my table in the test database to csv format

 mongoexport -u test -p 64823723zk -d test -c my -q {my_id:{'$lt':200}} --type=csv -f _id,username,a -o my.csv

Export Import

-D imported database-c imported table -- type csv/json -- file path

Example: import data in stu. json to the stu table in the test Database

 mongoimport -u test -p 123 -d test -c stu --type json --file ./stu.json

Mongodump

-D database name-c table name-o export path-f field1, field ...... field name

Example: Export binary bson structure data and index information from my table of the test database to the dump directory.
./Mongodump-u test-p 123-d test-c my-o./dump

Mongorestore

-D database -- dir = directory where bson and index information are stored

Example:

mongorestore -u test -p 123 -d test --dir=./dump/test/

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.