Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import data from mongodb to MySQL?

More specifically , can i use some bridge for this like first i should copy data to excel fro mongodb and then that excel sheets data could easily be imported into mysql by some scripts like as in Python.

like image 422
Yash Rastogi Avatar asked Sep 30 '22 08:09

Yash Rastogi


1 Answers

MongoDB does not offer any direct tool to do this, but you have many options to achieve this.

You can:

  • Write your own tool using your favorite language, that connect to MongoDB & MySQL and copy the data
  • Use mongoexport to create files and mysqlimport to reimport them into MySQL
  • Use an ETL (Extract, Transform, Load) that connect to MongoDB, allow you to transform the data and push them into MySQL. You can for example use Talend that has connector for MongoDB, bu you have many other solutions.

Note: Keep in mind that a simple document could contains complex structures such as Array/List, sub-documents, and even an Array of sub-documents. These structures can not be imported directly into a single table record, this is why most of the time you need a small transformation/mapping layer.

like image 55
Tug Grall Avatar answered Oct 02 '22 13:10

Tug Grall