Export MongoDB data based on time filtering
1. Convert the time in MongoDB to a timestamp first:
Isodate ("2016-12-01 00:00:00.000+08:00"). ValueOf ()
1334592000000
Then you can query based on the time stamp obtained.
Export:
- D is the database
- c is a collection
-o output filename
-csv refers to export to CSV format
-F indicates that those columns (fields) need to be exported
The filter conditions that are added to-Q
./mongoexport-h 127.0.0.1--port 20017-d xxx-c xxx--csv-f xxxx -Q ' {"Status_time": {$gt: New Date (1482681600 $lt: New Date (1482768000000)}} '-O xxxx
Import: Enter MySQL database:
LOAD DATA LOCAL INFILE ' export file full path ' into table name in database ' TERMINATED by ', ';
This article is from the "11993907" blog, please be sure to keep this source http://12003907.blog.51cto.com/11993907/1886618
Importing MongoDB portions of data into a MySQL database