开发者

MySQL export to MongoDB

I am looking to export an existing MySQL database table to seed a MongoDB database.

I would have thought this was a well trodden path, but it appears not to be, as I am coming up blank with a simple MySQLDUMP -> MongoDB JSON converter.

It won't take much effort to code 开发者_开发技巧up such a conversion utility.


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.


If you are Mac user you can use MongoHub which has a built in feature to import (& export) data from MySql databases.


If you are using java you can try this

http://code.google.com/p/sql-to-nosql-importer/


For a powerful conversion utility, check out Tungsten Replicator

I'm still looking int this one called SQLToNoSQLImporter, which is written in Java.


I've ut a little something up on GitHub - it's not even 80% there but it's growing for work and it might be something other of you could help me out on!

https://github.com/jaredwa/mysqltomongo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜