Let us say that you have a MySQL dump of a database table, with a load of data which ideally, you’d like to pull into a Mongo DB as json.
What you could do is…
Import data in to MySQL database
Usual kind of thing here, assuming you have a MySQL username for a created database:
Export data from MySQL database in json format
There is a cracking ruby gem mysql2xxxx which will export from a mysql database to various formats, including json.
You can drive it via code or a number of binaries are provided. So:
Importing the json straight in to your mongodb
Then you can use mongoimport to pull in the json. If your export from
mysql2json is surrounded by the square brackets, you’ll need the
--jsonArray option. Your command will need to be something like:
Simple three step transformation from MySQL dump to Mongo. You may know a better, more straightforward way of doing this, please add a comment if you do!