Migration guide: MySQL to SQL Server

Applies to: yesSQL Server (all supported versions)

In this guide, you learn how to migrate your MySQL databases to SQL Server.

For other migration guides, see Azure Database Migration Guides.

Prerequisites

Before you begin migrating your MySQL database to SQL Server:

Pre-migration

After you've met the prerequisites, you're ready to discover your source MySQL environment and assess the feasibility of your migration.

Assess

By using SSMA for MySQL, you can review database objects and data and assess databases for migration.

To create an assessment:

  1. Open SSMA for MySQL.

  2. On the File menu, select New Project.

  3. Enter the project name and a location to save your project and the migration target. Then select SQL Server in the Migrate To option.

    Screenshot that shows New Project.

  4. In the Connect to MySQL dialog box, enter connection details, and then connect to your MySQL server.

    Screenshot that shows Connect to MySQL.

  5. Select the MySQL databases you want to migrate.

    Screenshot that shows selecting the MySQL database you want to migrate.

  6. Right-click the MySQL database in MySQL Metadata Explorer, and select Create Report. Alternatively, you can select the Create Report tab in the upper-right corner.

    Screenshot that shows Create Report.

  7. Review the HTML report to understand conversion statistics and any errors or warnings. You can also open the report in Excel to get an inventory of MySQL objects and the effort required to perform schema conversions. The default location for the report is in the report folder within SSMAProjects, as shown here:

    drive:\Users\<username>\Documents\SSMAProjects\MySQLMigration\report\report_2016_11_12T02_47_55\.

    Screenshot that shows a conversion report.

Validate the type mappings

Validate the default data type mappings and change them based on requirements, if necessary. To do so:

  1. On the Tools menu, select Project Settings.

  2. Select the Type Mapping tab.

    Screenshot that shows Type Mapping.

  3. You can change the type mapping for each table by selecting the table in MySQL Metadata Explorer.

To learn more about conversion settings in SSMA for MySQL, see Project Settings.

Convert the schema

Converting database objects takes the object definitions from MySQL, converts them to similar SQL Server objects, and then loads this information into the SSMA for MySQL metadata. It doesn't load the information into the instance of SQL Server. You can then view the objects and their properties by using SQL Server Metadata Explorer.

During the conversion, SSMA for MySQL prints output messages to the output pane and error messages to the Error List pane. Use the output and error information to determine whether you have to modify your MySQL databases or your conversion process to obtain the desired conversion results.

To convert the schema:

  1. (Optional) To convert dynamic or ad-hoc queries, right-click the node and select Add Statement.

  2. Select the Connect to SQL Server tab.

    1. Enter connection details for your SQL Server instance.
    2. Select your target database from the drop-down list, or enter a new name, in which case a database will be created on the target server.
    3. Enter authentication details, and then select Connect.

    Screenshot that shows Connect to SQL Server.

  3. Right-click the MySQL database in MySQL Metadata Explorer, and then select Convert Schema. Alternatively, you can select the Convert Schema tab in upper-right corner.

    Screenshot that shows Convert Schema.

  4. After the conversion finishes, compare and review the converted objects to the original objects to identify potential problems and address them based on the recommendations.

    Screenshot that shows comparing and reviewing objects.

  5. Compare the converted Transact-SQL text to the original code, and review the recommendations.

    Screenshot that shows comparing and reviewing converted code.

  6. In the output pane, select Review results and review the errors in the Error List pane.

  7. Save the project locally for an offline schema remediation exercise. On the File menu, select Save Project. This step gives you an opportunity to evaluate the source and target schemas offline and perform remediation before you publish the schema to SQL Server.

To learn more, see Screenshot that shows converting MySQL databases..

Migration

After you have the necessary prerequisites in place and have completed the tasks associated with the pre-migration stage, you're ready to perform the schema and data migration.

You have two options for migrating data:

  • Client-side data migration

    • To perform client-side data migration, select the Client Side Data Migration Engine option in the Project Settings dialog box.

    Note

    When SQL Express edition is used as the target database, only client-side data migration is allowed and server-side data migration isn't supported.

  • Server-side data migration

    • Before you perform data migration on the server side, ensure that:
      • The SSMA for MySQL Extension Pack is installed on the instance of SQL Server.
      • The SQL Server Agent service is running on the instance of SQL Server.
    • To perform server-side data migration, select the Server Side Data Migration Engine option in the Project Settings dialog box.

Important

If you plan to use the Server Side Data Migration Engine, before you migrate data, you must install the SSMA for MySQL Extension Pack and the MySQL providers on the computer that's running SSMA for MySQL. The SQL Server Agent service must also be running. For more information about how to install the extension pack, see Installing SQL Server Migration Assistant Components on SQL Server (MySQL to SQL).

To publish your schema and migrate the data:

  1. Publish the schema by right-clicking the database in SQL Server Metadata Explorer and selecting Synchronize with Database. This action publishes the MySQL database to the SQL Server instance.

    Screenshot that shows Synchronize with Database.

  2. Review the mapping between your source project and your target.

    Screenshot that shows reviewing the synchronization with the database.

  3. Migrate the data by right-clicking the database or object you want to migrate in MySQL Metadata Explorer and selecting Migrate Data. Alternatively, you can select the Migrate Data tab. To migrate data for an entire database, select the check box next to the database name. To migrate data from individual tables, expand the database, expand Tables, and then select the check boxes next to the tables. To omit data from individual tables, clear the check boxes.

    Screenshot that shows Migrate Data.

  4. After migration is completed, view the Data Migration Report.

    Screenshot that shows the Data Migration Report.

  5. Connect to your SQL Server instance by using SQL Server Management Studio, and validate the migration by reviewing the data and schema.

    Screenshot that shows validation in SQL Server Management Studio.

Post-migration

After you've successfully completed the migration stage, you need to complete a series of post-migration tasks to ensure that everything is functioning as smoothly and efficiently as possible.

Remediate applications

After you've migrated the data to the target environment, all the applications that formerly consumed the source need to start consuming the target. Accomplishing this task will require changes to the applications in some cases.

Perform tests

The test approach for database migration consists of the following activities:

  1. Develop validation tests: To test database migration, you need to use SQL queries. You must create the validation queries to run against both the source and the target databases. Your validation queries should cover the scope you've defined.
  2. Set up a test environment: The test environment should contain a copy of the source database and the target database. Be sure to isolate the test environment.
  3. Run validation tests: Run validation tests against the source and the target, and then analyze the results.
  4. Run performance tests: Run performance tests against the source and the target, and then analyze and compare the results.

Optimize

The post-migration phase is crucial for reconciling any data accuracy issues, verifying completeness, and addressing performance issues with the workload.

Note

For more information about these issues and the steps to mitigate them, see the Post-migration validation and optimization guide.

Migration assets

For more assistance with completing this migration scenario, see the following resource. It was developed in support of a real-world migration project engagement.

Title Description
Data Workload Assessment Model and Tool This tool provides suggested "best fit" target platforms, cloud readiness, and application or database remediation level for a given workload. It offers simple, one-click calculation and report generation that helps to accelerate large estate assessments by providing an automated and uniform target platform decision process.

The Data SQL Engineering team developed these resources. This team's core charter is to unblock and accelerate complex modernization for data platform migration projects to Microsoft's Azure data platform.

Next steps