The title is self explanatory. Is there a way of directly doing such kind of importing?
-
3also [covered on dba.stackexchange](http://dba.stackexchange.com/q/20078/1580) – David LeBauer Jun 28 '12 at 16:55
-
Epic question bro! I finaly managed to import the bak file from my crappy hosting provider where all SQL tools were broken. – Piotr Kula Sep 06 '12 at 13:52
10 Answers
The .BAK files from SQL server are in Microsoft Tape Format (MTF) ref: http://www.fpns.net/willy/msbackup.htm
The bak file will probably contain the LDF and MDF files that SQL server uses to store the database.
You will need to use SQL server to extract these. SQL Server Express is free and will do the job.
So, install SQL Server Express edition, and open the SQL Server Powershell. There execute sqlcmd -S <COMPUTERNAME>\SQLExpress
(whilst logged in as administrator)
then issue the following command.
restore filelistonly from disk='c:\temp\mydbName-2009-09-29-v10.bak';
GO
This will list the contents of the backup - what you need is the first fields that tell you the logical names - one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM disk='c:\temp\mydbName-2009-09-29-v10.bak'
WITH
MOVE 'mydbName' TO 'c:\temp\mydbName_data.mdf',
MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf';
GO
At this point you have extracted the database - then install Microsoft's "Sql Web Data Administrator". together with this export tool and you will have an SQL script that contains the database.

- 6,286
- 1
- 24
- 41

- 19,247
- 4
- 40
- 67
-
4The problem is that SQL Server 2008 Express Edition can only handle database files that are 10GB and smaller. I have a 30GB file I have to work with. The Internet connection at work is too slow to download the 4GB .iso image of the full SQL Server 2008 R2 version, which I get for free from dreamspark.com as a student. So I have this exact same question. – Geoffrey May 12 '11 at 14:21
-
-
Are you sure about the file format being MTF? When I try to use the [command-line mtf-tool](http://layton-graphics.com/mtf/) to list the contents of a `.bak` file, I get an error... – Mikhail T. Jan 03 '18 at 20:11
-
@MikhailT.when I wrote this answer nearly 10 years ago I'm fairly sure that MTF was being used; this may have since changed. – Richard Harrison Jan 05 '18 at 10:07
MySql have an application to import db from microsoft sql. Steps:
- Open MySql Workbench
- Click on "Database Migration" (if it do not appear you have to install it from MySql update)
- Follow the Migration Task List using the simple Wizard.

- 735
- 1
- 10
- 14
-
3
-
11@Sean, if you see a problem with MySQL Workbench then file a bug report. Migration is a complicated matter, so implementations need a few rounds to become stable. – Mike Lischke Dec 19 '13 at 08:42
I did not manage to find a way to do it directly.
Instead I imported the bak file into SQL Server 2008 Express, and then used MySQL Migration Toolkit.
Worked like a charm!

- 6,143
- 15
- 46
- 52
-
Yes the import worked fine for me. Right click on the 'databases' node click import- First select the BAK file then choose database - It automatically gets the database name from the loaded .bak file and puts it into the list.(to create the new database) Select that and click import.. Woohoo - 6 days later! – Piotr Kula Sep 06 '12 at 13:50
-
MySQL Migration Toolkit has reached EOL. see http://dev.mysql.com/downloads/gui-tools/5.0.html – Jakob Mar 13 '13 at 09:45
-
1The 'Database Migration' functionality is now part of [MySQL Workbench](http://dev.mysql.com/downloads/tools/workbench/) – dazweeja Feb 11 '14 at 23:05
In this problem, the answer is not updated in a timely. So it's happy to say that in 2020 Migrating to MsSQL
into MySQL
is that much easy. An online converter like RebaseData will do your job with one click. You can just upload your .bak
file which is from MsSQL
and convert it into .sql
format which is readable to MySQL
.
Additional note: This can not only convert your .bak
files but also this site is for all types of Database migrations that you want.

- 3,894
- 11
- 41
- 63
-
3Note we paid for RebaseData to have access to the Premium features (as Free only lets you do very small files) and we haven't been able to get RebaseData working with our nearly 35GB .bak file no matter what we tried: CLI tool, upload via API, etc. It pretty much ran out of memory everywhere (even though our server has 32GB memory and we gave it all we could) – Titi Dec 08 '20 at 09:38
-
3Also worth noting they have a '7 day money back guarantee' if you can't convert your files and even though I emailed support with a very detailed explanation of everything we tried and hoping they'll be able to have a look on their side at the uploaded file via the API we still haven't heard back from them in over 2 weeks. – Titi Dec 08 '20 at 09:40
Although my MySQL background is limited, I don't think you have much luck doing that. However, you should be able to migrate over all of your data by restoring the db to a MSSQL server, then creating a SSIS or DTS package to send your tables and data to the MySQL server.
hope this helps

- 4,398
- 6
- 28
- 36
The method I used included part of Richard Harrison's method:
So, install SQL Server 2008 Express edition,
This requires the download of the Web Platform Installer "wpilauncher_n.exe" Once you have this installed click on the database selection ( you are also required to download Frameworks and Runtimes)
After instalation go to the windows command prompt and:
use sqlcmd -S \SQLExpress (whilst logged in as administrator)
then issue the following command.
restore filelistonly from disk='c:\temp\mydbName-2009-09-29-v10.bak'; GO This will list the contents of the backup - what you need is the first fields that tell you the logical names - one will be the actual database and the other the log file.
RESTORE DATABASE mydbName FROM disk='c:\temp\mydbName-2009-09-29-v10.bak' WITH MOVE 'mydbName' TO 'c:\temp\mydbName_data.mdf', MOVE 'mydbName_log' TO 'c:\temp\mydbName_data.ldf'; GO
I fired up Web Platform Installer and from the what's new tab I installed SQL Server Management Studio and browsed the db to make sure the data was there...
At that point i tried the tool included with MSSQL "SQL Import and Export Wizard" but the result of the csv dump only included the column names...
So instead I just exported results of queries like "select * from users" from the SQL Server Management Studio

- 778
- 2
- 11
- 28
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.

- 24,293
- 14
- 43
- 56
SQL Server databases are very Microsoft proprietary. Two options I can think of are:
Dump the database in CSV, XML or similar format that you'd then load into MySQL.
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.

- 64,563
- 18
- 145
- 216

- 3,957
- 1
- 21
- 21
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.

- 13,649
- 2
- 54
- 45
-
-
Last commit was over 5 years ago. I would use it with a grain of salt unless you're keen on fixing problems and hopefully forking it with fixes. – Joshua Pinter Aug 25 '23 at 12:41
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.

- 9,090
- 8
- 46
- 59