Importing MongoDB portions of data into the MySQL database

Source: Internet
Author: User

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

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.