MongoDB Data Import and export
The Mongoexport in MongoDB is responsible for data export
The Mongoimport in MongoDB is responsible for data import
The Mongoexport tool allows you to export data tables in MongoDB to a file in JSON or CSV format
Export CSV Format example:
Export user,createtime,gold,level,region,vip_level item data from data table user in data gamedb to file/home/data/user.csv
-D: Indicates which library to use, in this case gamedb
-C: Indicates the collection to be exported, in this case the user
-O: Indicates the name of the file to be exported, in this case user.csv
-csv: Indicates that you want to export to CSV format
-F: Indicates that you need to export data for user, createtime, gold, level, region, vip_level columns
mongoexport-d gamedb-c user--csv-f User,createtime,gold,level,region,vip_level-o/home/data/user.csv
Export JSON format example:
Export data from data table user in data gamedb to file/home/data/user.json, export JSON format without specifically pointing out data items in the packet
mongoexport-d gamedb-c User-o/home/data/user.json
MongoDB Data Import and export