How to migrate data from mongodb to mysql?

MySQL 5.7 has a new JSON data type, that can be very convenient.

You can create a table at MySQL to receive the JSON messages AS IS, and then use SQL to query it or do a post processing to load the data in a structured set of database tables.

Check this out: https://dev.mysql.com/doc/refman/5.7/en/json.html


There is no official library to do this. But you can use mongoexport feature from mongoDB to export it in a CSV format and mysqlimport to import them into MySQL.

Here are links to the documentation MySQL import and MongoDB Export.


One more method you can try to write a program in one of your favorite language and read from MongoDB and write into MySQL

Tags:

Mysql

Mongodb