如何将SQL Server数据库导出到MySQL?

发布于 2024-09-27 19:20:16 字数 359 浏览 3 评论 0 原文

我正在尝试从 SQL Server 数据库备份文件 (.bak) 转换为 MySQL。 这个问题和答案非常有用,并且我已成功导入数据库,但现在仍坚持导出到 MySQL。

建议使用MySQL Migration Toolkit,但似乎已被MySQL Workbench取代。是否可以使用 MySQL Workbench 以与迁移工具相同的方式从 SQL Server 迁移?

或者迁移工具包是否仍然可用?

I'm trying to convert from a SQL Server database backup file (.bak) to MySQL. This question and answers have been very useful, and I have successfully imported the database, but am now stuck on exporting to MySQL.

The MySQL Migration Toolkit was suggested, but seems to have been replaced by the MySQL Workbench. Is it possible to use the MySQL Workbench to migrate from SQL Server in the same way that the migration tool worked?

Or is the Migration Toolkit still available somewhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

抽个烟儿 2024-10-04 19:20:16

您可以使用 MySQL Workbench,它提供了一种将数据和应用程序从 Microsoft SQL Server 快速迁移到MySQL 花费更少的时间和精力。

该工具具有许多很酷的功能,例如:

  • 数据库迁移 - 支持从 Microsoft SQL Server、Sybase ASE 和 PostgreSQL 进行迁移。
  • 迁移项目管理 - 允许配置、复制、编辑、执行和计划迁移。

阅读更多
http://www.mysql.com/products/workbench/migrate/

You can use MySQL Workbench which provides a way to quickly migrate data and applications from Microsoft SQL Server to MySQL employing less time and effort.

This tool has a lot of cool features like:

  • Database migrations - enables migrations from Microsoft SQL Server, Sybase ASE and PostgreSQL.
  • Migration project management - allows migrations to be configured, copied, edited, executed and scheduled.

Read more
http://www.mysql.com/products/workbench/migrate/

几味少女 2024-10-04 19:20:16

我使用 sqlyog 从 mssql 迁移到 mysql。我尝试了迁移工具包和工作台,但喜欢 sqlyog,因为它的SJA。我可以安排导入过程,并可以使用 WHERE 子句进行增量导入。

在此处输入图像描述

I use sqlyog to migrate from mssql to mysql. I tried Migration toolkit and workbench but liked sqlyog for its SJA. I could schedule the import process and could do incremental import using WHERE clause.

enter image description here

完美的未来在梦里 2024-10-04 19:20:16

PhpMyAdmin 有一个导入向导,可以让您导入 MSSQL 文件类型。

请参阅http://dev.mysql.com/doc/refman/ 5.1/en/sql-mode.html 了解其支持的数据库脚本类型。

PhpMyAdmin has a Import wizard that lets you import a MSSQL file type too.

See http://dev.mysql.com/doc/refman/5.1/en/sql-mode.html for the types of DB scripts it supports.

江挽川 2024-10-04 19:20:16

将其一一转换为 MySQL 查询

如果您有 MSSQL 兼容的 SQL 转储,您可以使用此在线工具http://burrist .com/mstomy.php

希望它节省了您的时间

if you have a MSSQL compatible SQL dump you can convert it to MySQL queries one by one using this online tool

http://burrist.com/mstomy.php

Hope it saved your time

他不在意 2024-10-04 19:20:16

如上所述,如果您的数据中包含制表符、逗号或换行符,那么使用 CSV 导出和导入数据将会非常困难。值将溢出字段,并且您将收到错误。如果任何长字段包含带有换行符的多行文本,这个问题会更严重。

在这些情况下,我的方法是使用 BCP 命令行实用程序从 SQL Server 导出数据,然后使用 MySQL 中的 LOAD DATA INFILE .. INTO TABLE 命令读回数据文件。BCP 是最古老的 SQL Server 之一命令行实用程序(可以追溯到 SQL Server - v6.5 的诞生),但它仍然存在,并且仍然是获取数据的最简单、最可靠的方法之一。

要使用此技术,您需要在 MySQL 中创建具有相同或等效架构的每个目标表。我通过右键单击 SQL 企业管理器中的数据库,然后单击任务 -> 生成脚本... 并为所有表创建 SQL 脚本来完成此操作。然后,您必须手动将脚本转换为 MySQL 兼容的 SQL(这绝对是工作中最糟糕的部分),最后在 MySQL 数据库上运行 CREATE TABLE 命令,这样您就可以按列将表与 SQL Server 版本相匹配,为空并准备好数据。

然后,从MS-SQL端导出数据,如下所示。

bcp DatabaseName..TableName out TableName.dat -q -c -T -S ServerName -r \0 -t !\t!

(如果您使用的是 SQL Server Express,请使用 -S 值,如下所示: -S "ComputerName\SQLExpress")

这将创建一个名为 TableName.dat 的文件,其中的字段由 ![tab]! 分隔!和由 \0 NUL 字符分隔的行。

现在将 .dat 文件复制到 MySQL 服务器上的 /tmp 并加载到 MySQL 端,如下所示:

LOAD DATA INFILE '/tmp/TableName.dat' INTO TABLE TableName FIELDS TERMINATED BY '!\t!' LINES TERMINATED BY '\0';

不要忘记表(本例中的 TableName)必须已在 MySQL 端创建。

当涉及到转换 SQL 模式时,这个过程是痛苦的手动过程,但是它甚至适用于最困难的数据,并且因为它使用平面文件,所以您永远不需要说服 SQL Server 与 MySQL 对话,反之亦然。

As mentioned above, if your data contains tab characters, commas, or newlines in your data then it's going to be very hard to export and import it with CSV. Values will overflow out of the fields and you will get errors. This problem is even worse if any of your long fields contain multi-line text with newline characters in them.

My method in these cases is to use the BCP command-line utility to export the data from SQL server, then use LOAD DATA INFILE .. INTO TABLE command in MySQL to read the data file back in. BCP is one of the oldest SQL Server command line utilities (dating back to the birth of SQL server - v6.5) but it is still around and still one of the easiest and most reliable ways to get data out.

To use this technique you need to create each destination table with the same or equivalent schema in MySQL. I do that by right clicking the Database in SQL enterprise manager, then Tasks->Generate Scripts... and create a SQL script for all the tables. You must then convert the script to MySQL compatible SQL by hand (definitely the worst part of the job) and finally run the CREATE TABLE commands on the MySQL database so you have matching tables to the SQL server versions column-wise, empty and ready for data.

Then, export the data from the MS-SQL side as follows.

bcp DatabaseName..TableName out TableName.dat -q -c -T -S ServerName -r \0 -t !\t!

(If you're using SQL Server Express, use a -S value like so: -S "ComputerName\SQLExpress")

That will create a file named TableName.dat, with fields delimited by ![tab]! and rows delimited by \0 NUL characters.

Now copy the .dat files into /tmp on the MySQL server and load on the MySQL side like so:

LOAD DATA INFILE '/tmp/TableName.dat' INTO TABLE TableName FIELDS TERMINATED BY '!\t!' LINES TERMINATED BY '\0';

Don't forget that the tables (TableName in this example) must be created already on the MySQL side.

This procedure is painfully manual when it comes to converting the SQL schema over, however it works for even the most difficult of data and because it uses flat files you never need to persuade SQL Server to talk to MySQL, or vice versa.

网名女生简单气质 2024-10-04 19:20:16

您可以使用数据加载器工具轻松完成此操作。在使用这个工具之前我已经这样做过并且发现它很好。

You can do this easily by using Data Loader tool. I have already done this before using this tool and found it good.

兮子 2024-10-04 19:20:16

看来您是正确的:迁移工具包将与 MySQL Workbench 集成 - 但我认为这还没有完成。请参阅 MySQL GUI 工具(包括迁移工具包)的生命周期终止公告:

http ://www.mysql.com/support/eol-notice.html

MySQL 维护 MySQL GUI 工具包的档案:

http://dev.mysql.com/downloads/gui-tools/5.0.html

It looks like you correct: The Migration Toolkit is due to be integrated with MySQL Workbench - but I do not think this has been completed yet. See the End-of-life announcement for MySQL GUI Tools (which included the Migration Toolkit):

http://www.mysql.com/support/eol-notice.html

MySQL maintain archives of the MySQL GUI Tools packages:

http://dev.mysql.com/downloads/gui-tools/5.0.html

圈圈圆圆圈圈 2024-10-04 19:20:16

我在 MySQL 迁移工具包的“高级”选项卡上使用以下连接字符串来连接到 SQL Server 2008 实例:

jdbc:jtds:sqlserver://"sql_server_ip_address":1433/<db_name>;Instance=<sqlserver_instanceName>;user=sa;password=PASSWORD;namedPipe=true;charset=utf-8;domain= 

通常该参数具有“systemName\instanceName”。但在上面,不要添加“systemName\”(仅使用 InstanceName)。

要检查 instanceName 应该是什么,请转到 services.msc 并检查 MSSQL 实例的 DisplayName。它显示类似于 MSSQL$instanceName。

希望这对 mysql 迁移工具包的 MSSQL 连接有所帮助。

I used the below connection string on the Advanced tab of MySQL Migration Tool Kit to connect to SQL Server 2008 instance:

jdbc:jtds:sqlserver://"sql_server_ip_address":1433/<db_name>;Instance=<sqlserver_instanceName>;user=sa;password=PASSWORD;namedPipe=true;charset=utf-8;domain= 

Usually the parameter has "systemName\instanceName". But in the above, do not add "systemName\" (use only InstanceName).

To check what the instanceName should be, go to services.msc and check the DisplayName of the MSSQL instance. It shows similar to MSSQL$instanceName.

Hope this help in MSSQL connectivity from mysql migration toolKit.

羁客 2024-10-04 19:20:16

MySQL 迁移工具包 (1.1.10) 仍可从此处下载:

http://downloads.mysql.com/archives.php?p=MySQLDeveloperSuite&v=1.1.10

MySQL Migration Toolkit (1.1.10) still available for download from here:

http://downloads.mysql.com/archives.php?p=MySQLDeveloperSuite&v=1.1.10

对你而言 2024-10-04 19:20:16

我有一些数据必须从 mssql 获取到 mysql,但很难找到解决方案。所以我最后所做的(有点啰嗦,但作为最后的手段它是有效的)是:

  • 在sql server management studio express中打开mssql数据库(我使用2005)
  • 依次打开每个表并
  • 单击左上角框选择整个表格:

  • 将数据复制到剪贴板(ctrl + v)

  • 打开 ms excel
  • 从剪贴板粘贴数据
  • 将 excel 文件另存为 .csv
  • 对每个表重复上述操作
  • 现在您应该能够将数据导入 mysql

希望这会有所帮助

I had some data I had to get from mssql into mysql, had difficulty finding a solution. So what I did in the end (a bit of a long winded way to do it, but as a last resort it works) was:

  • Open the mssql database in sql server management studio express (I used 2005)
  • Open each table in turn and
  • Click the top left corner box to select whole table:

  • Copy data to clipboard (ctrl + v)

  • Open ms excel
  • Paste data from clipboard
  • Save excel file as .csv
  • Repeat the above for each table
  • You should now be able to import the data into mysql

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文