How to import a SQL Server .bak file into MySQL?

2019-01-10 01:27发布

The title is self explanatory. Is there a way of directly doing such kind of importing?

10条回答
走好不送
2楼-- · 2019-01-10 01:56
  1. Open SQL Server Management Studio on your local machine.
  2. Right click the Databases folder. From the pop-up menu, select New Database.
  3. Enter a database name, and then click Ok.
  4. Right click the new database icon. From the pop-up menu, select Tasks -> Restore -> Database.
  5. Select the From Device option, and then click the browse button.
  6. Click Add and navigate to the appropriate file. Click Ok.
  7. In the Restore Database window, select the checkbox next to your BAK file.
  8. Switch to the Options page. Select the Overwrite the existing database checkbox. Click Ok.
  9. Verify the contents of your database, which is now active on your local machine.
查看更多
劫难
3楼-- · 2019-01-10 01:58

For those attempting Richard's solution above, here are some additional information that might help navigate common errors:

1) When running restore filelistonly you may get Operating system error 5(Access is denied). If that's the case, open SQL Server Configuration Manager and change the login for SQLEXPRESS to a user that has local write privileges.

2) @"This will list the contents of the backup - what you need is the first fields that tell you the logical names" - if your file lists more than two headers you will need to also account for what to do with those files in the RESTORE DATABASE command. If you don't indicate what to do with files beyond the database and the log, the system will apparently try to use the attributes listed in the .bak file. Restoring a file from someone else's environment will produce a 'The path has invalid attributes. It needs to be a directory' (as the path in question doesn't exist on your machine). Simply providing a MOVE statement resolves this problem.

In my case there was a third FTData type file. The MOVE command I added:

MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf',
MOVE 'sysft_...' TO 'c:\temp\other';

in my case I actually had to make a new directory for the third file. Initially I tried to send it to the same folder as the .mdf file but that produced a 'failed to initialize correctly' error on the third FTData file when I executed the restore.

查看更多
成全新的幸福
4楼-- · 2019-01-10 02:07

I highly doubt it. You might want to use DTS/SSIS to do this as Levi says. One think that you might want to do is start the process without actually importing the data. Just do enough to get the basic table structures together. Then you are going to want to change around the resulting table structure, because whatever structure tat will likely be created will be shaky at best.

You might also have to take this a step further and create a staging area that takes in all the data first n a string (varchar) form. Then you can create a script that does validation and conversion to get it into the "real" database, because the two databases don't always work well together, especially when dealing with dates.

查看更多
Anthone
5楼-- · 2019-01-10 02:12

SQL Server databases are very Microsoft proprietary. Two options I can think of are:

  1. Dump the database in CSV, XML or similar format that you'd then load into MySQL.

  2. Setup ODBC connection to MySQL and then using DTS transport the data. As Charles Graham has suggested, you may need to build the tables before doing this. But that's as easy as a cut and paste from SQL Enterprise Manager windows to the corresponding MySQL window.

查看更多
ゆ 、 Hurt°
6楼-- · 2019-01-10 02:14

MySql have an application to import db from microsoft sql. Steps:

  1. Open MySql Workbench
  2. Click on "Database Migration" (if it do not appear you have to install it from MySql update)
  3. Follow the Migration Task List using the simple Wizard.
查看更多
祖国的老花朵
7楼-- · 2019-01-10 02:14

The .bak file from SQL Server is specific to that database dialect, and not compatible with MySQL.

Try using etlalchemy to migrate your SQL Server database into MySQL. It is an open-sourced tool that I created to facilitate easy migrations between different RDBMS's.

Quick installation and examples are provided here on the github page, and a more detailed explanation of the project's origins can be found here.

查看更多
登录 后发表回答