MySQL export to MongoDB MySQL export to MongoDB mongodb mongodb

MySQL export to MongoDB


There are a method that doesn't require you to use any other software than mysql and mongodb utilities. The disadvantage is that you have to go table by table, but in your case you only need to migrate one table, so it won't be painful.

I followed this tutorial. Relevant parts are:

  1. Get a CSV with your data. You can generate one with the following query in mysql.

    SELECT [fields] INTO outfile 'user.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM [table]
  2. Finally, import the file using mongoimport. That's all


If you're using Ruby, you can also try: Mongify

It will read your mysql database, build a translation file and allow you to map the information.

It supports:

  • Updating internal IDs (to BSON ObjectID)
  • Updating referencing IDs
  • Type Casting values
  • Embedding Tables into other documents
  • Before filters (to change data manually)
  • and much much more...

Read more about it at: http://mongify.com/getting_started.html


MongoVue is a new project that contains a MySQL import:MongoVue. I have not used that feature.