5

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.

Yash Rastogi
  • 465
  • 4
  • 14
  • http://docs.mongodb.org/manual/reference/program/mongoexport/#export-in-csv-format, http://stackoverflow.com/questions/3635166/how-to-import-csv-file-to-mysql-table - Does this help? – BatScream Nov 25 '14 at 05:35
  • my question is importing data from mongodb to mysql . Can i get some stuff regarding this. – Yash Rastogi Nov 25 '14 at 05:41
  • You can write a Python (or choose your favourite language) script that talks directly to both databases, or you could use command-line tools like [`mongoexport`](http://docs.mongodb.org/manual/reference/program/mongodump/) and [`mysqlimport`](http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html). Generally you'd want to consider different (and more appropriate) data models rather than just a straight copy between relational & non-relational databases. Going by way of Excel is completely unnecessary. – Stennie Nov 25 '14 at 05:42

1 Answers1

4

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.

Tug Grall
  • 3,410
  • 1
  • 14
  • 16