MySQL 导出到 MongoDB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3180709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:29:07  来源:igfitidea点击:

MySQL export to MongoDB

mysqlmongodb

提问by Alan Williamson

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

我希望导出现有的 MySQL 数据库表来为 MongoDB 数据库提供种子。

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.

我原以为这是一条很好的路径,但它似乎不是,因为我用一个简单的 MySQLDUMP -> MongoDB JSON 转换器来空白。

It won't take much effort to code up such a conversion utility.

编写这样的转换实用程序不会花费太多精力。

回答by Iván Rodríguez Torres

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.

有一种方法不需要您使用除 mysql 和 mongodb 实用程序之外的任何其他软件。缺点是要一张一张表走,但你的情况只需要迁移一张表,所以不会很痛苦。

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
  1. 使用您的数据获取 CSV。您可以在 mysql 中使用以下查询生成一个。

    SELECT [fields] INTO outfile 'user.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' FROM [table]
    
  2. 最后,使用mongoimport. 就这样

回答by Andrew K

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

如果你使用 Ruby,你也可以试试:Mongify

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

它将读取您的 mysql 数据库,构建一个翻译文件并允许您映射信息。

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...
  • 更新内部 ID(到 BSON ObjectID)
  • 更新参考 ID
  • 类型转换值
  • 将表格嵌入其他文档
  • 过滤器之前(手动更改数据)
  • 还有更多……

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

阅读更多相关信息:http: //mongify.com/getting_started.html

回答by Amala

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

MongoVue 是一个包含 MySQL 导入的新项目: MongoVue。我没用过那个功能。

回答by cedric

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

如果您是 Mac 用户,您可以使用MongoHub,它具有从 MySql 数据库导入(和导出)数据的内置功能。

回答by sathis

If you are using java you can try this

如果你使用的是 java 你可以试试这个

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

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

回答by FullStack

For a powerful conversion utility, check out Tungsten Replicator

如需强大的转换实用程序,请查看Tungsten Replicator

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

我仍在寻找一个名为SQLToNoSQLImporter 的工具,它是用 Java 编写的。

回答by Jared Alessandroni

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!

我在 GitHub 上有一些东西 - 它甚至不到 80%,但它正在增长,而且它可能是你们其他人可以帮助我的东西!

https://github.com/jaredwa/mysqltomongo

https://github.com/jaredwa/mysqltomongo