将.bak导入MySQL(.sql) [英] Import .bak to MySQL (.sql)
问题描述
我想将MS SQL SERVER2008 R2数据库备份导入MySQL服务器.关于如何将.bak转换为.sql以便可以将其导入到MySQL数据库服务器的任何帮助?
我已经阅读了与此相关的其他主题,但到目前为止都没有奏效.
谢谢.
您可以将数据库还原到SQL Server的本地版本(您可以下载免费的评估版来做到这一点):
http://msdn.microsoft.com/en-us/evalcenter/ff459612.aspx
然后,您可以使用Management Studio中的导入/导出向导将表和其他对象传输到MySQL数据库(您可能需要在本地安装其他ODBC驱动程序,以便SQL Server建立与MySQL的连接).>
编辑
将数据库还原到SQL Server时,请勿使用笨拙的UI.使用实际的 RESTORE DATABASE
命令.例如:
从磁盘还原数据库foo ='c:\ path \ foo.bak';
现在,您可能会发现原始数据库是使用放置在本地不存在的驱动器或文件夹上的文件创建的.因此,我建议临时创建一个非常简单的文件夹,名为 c:\ db_temp \
,赋予 Everyone
帐户修改权限,然后运行以下命令:
从磁盘恢复文件列表='c:\ path \ foo.bak';
这将返回如下结果集:
LogicalName物理名称----------- ------------Foo C:\ ... \ foo.mdfFoo_log C:\ ... \ foo_log.ldf
您需要根据上面的结果构建一个 RESTORE DATABASE
命令,如下所示:
从磁盘还原数据库foo ='c:\ path \ foo.bak'通过将"Foo"移动到"c:\ db_temp \ foo.mdf",移动'Foo_log'到'c:\ db_temp \ foo_log.ldf';
I want to import a MS SQL SERVER2008 R2 database backup to MySQL Server. Any help on how I can convert the .bak to a .sql so that it can be imported to a MySQL database server?
I have read other threads regarding this but none have worked so far.
Thank you.
You can restore the database to a local version of SQL Server (you can download the free evaluation edition to do this):
http://msdn.microsoft.com/en-us/evalcenter/ff459612.aspx
Then you can use the import/export wizard in Management Studio to transfer your tables and other objects to your MySQL database (you may need additional ODBC drivers installed locally in order for SQL Server to establish a connection to MySQL).
EDIT
When restoring the database to SQL Server, don't use the clunky UI. Use an actual RESTORE DATABASE
command. For example:
RESTORE DATABASE foo FROM DISK = 'c:\path\foo.bak';
Now, you may find that the original database was created with files placed on drives or folders that don't exist locally. So I suggest creating a very simple folder, temporarily, called c:\db_temp\
, giving the Everyone
account modify privileges, and then running the following:
RESTORE FILELISTONLY FROM DISK = 'c:\path\foo.bak';
This will return a resultset like:
LogicalName PhysicalName
----------- ------------
Foo C:\...\foo.mdf
Foo_log C:\...\foo_log.ldf
You need to build a RESTORE DATABASE
command something like the following, based on the result above:
RESTORE DATABASE foo FROM DISK = 'c:\path\foo.bak'
WITH MOVE 'Foo' TO 'c:\db_temp\foo.mdf',
MOVE 'Foo_log' TO 'c:\db_temp\foo_log.ldf';
这篇关于将.bak导入MySQL(.sql)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!