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

前端 未结 10 613
天涯浪人
天涯浪人 2020-12-02 04:52

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

相关标签:
10条回答
  • 2020-12-02 05:31

    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.
    0 讨论(0)
  • 2020-12-02 05:34

    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!

    0 讨论(0)
  • 2020-12-02 05:38

    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.

    0 讨论(0)
  • 2020-12-02 05:38

    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

    0 讨论(0)
  • 2020-12-02 05:39

    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.

    0 讨论(0)
  • 2020-12-02 05:42

    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

    0 讨论(0)
提交回复
热议问题