如何将数据从 mongodb 迁移到 mysql?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34855040/
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 21:32:33  来源:igfitidea点击:

How to migrate data from mongodb to mysql?

mysqlmongodb

提问by Placinta Alexandru

I am currently working on an application like to analitics, i has Angularjs appwhich communicates with Spring REST Client Appfrom which user creates token(trackingID) and use generated script with this id putting on his website to collect information about visitor's actions through another Spring REST tracking App, for tracking appi am using as mongodb to collect visitor actions/visitor info for fast insertion, but for rest client appmysql with user/accounts details. My question is how to migrate mongo data from tracking app to mysql maybe for getting posibility of join for easily and fastest way of analyze data with any kind of filters from angularjs client app, to create manually any workers that periodically will transfer data from last point to present state from mongo to mysql, or are any existed tools that can be setted for this transfer?

我目前正在开发一个类似于analitics 的应用程序,我有一个Angularjs 应用程序,它与Spring REST 客户端应用程序通信,用户从中创建令牌(trackingID)并使用生成的脚本将此 ID 放在他的网站上以通过另一个Spring收集有关访问者操作的信息REST 跟踪应用程序,用于跟踪应用程序,我用作 mongodb 来收集访问者操作/访问者信息以快速插入,但用于其他客户端应用程序带有用户/帐户详细信息的 mysql。我的问题是如何将 mongo 数据从跟踪应用程序迁移到 mysql 也许是为了获得加入的可能性,以便使用来自 angularjs 客户端应用程序的任何类型的过滤器轻松快速地分析数据,手动创建任何定期从最后一点传输数据的工作人员显示从 mongo 到 mysql 的状态,或者是否有任何可以为此传输设置的现有工具?

回答by Sumit Kumar

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

没有官方图书馆可以做到这一点。但是您可以使用mongoexportmongoDB 中的功能将其导出为 CSV 格式并将mysqlimport其导入 MySQL。

Here are links to the documentation MySQL importand MongoDB Export.

这里是文档MySQL 导入MongoDB 导出的链接


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


您可以尝试用您最喜欢的语言之一编写程序并从 MongoDB 读取并写入 MySQL 的另一种方法

回答by Daniel Carvalho

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

MySQL 5.7 有一个新的 JSON 数据类型,非常方便。

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.

您可以在 MySQL 上创建一个表来按原样接收 JSON 消息,然后使用 SQL 对其进行查询或进行后处理以将数据加载到一组结构化的数据库表中。

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

看看这个:https: //dev.mysql.com/doc/refman/5.7/en/json.html

回答by lead

You can download a trial version of Studio 3T for Mongo and export your database to SQL (or JSON) directly

您可以下载适用于 Mongo 的 Studio 3T 试用版并将您的数据库直接导出到 SQL(或 JSON)