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.