Migration guide: MySQL to SQL Server
Applies to: SQL 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.
Before you begin migrating your MySQL database to SQL Server:
- Verify that your source environment is supported. Currently, MySQL 5.6 and 5.7 are supported.
- Get SQL Server Migration Assistant for MySQL (SSMA for MySQL).
- Get connectivity and sufficient permissions to access both the source and target.
After you've met the prerequisites, you're ready to discover your source MySQL environment and assess the feasibility of your migration.
By using SSMA for MySQL, you can review database objects and data and assess databases for migration.
To create an assessment:
Open SSMA for MySQL.
On the File menu, select New Project.
Enter the project name and a location to save your project and the migration target. Then select SQL Server in the Migrate To option.
In the Connect to MySQL dialog box, enter connection details, and then connect to your MySQL server.
Select the MySQL databases you want to migrate.
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.
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:
Validate the type mappings
Validate the default data type mappings and change them based on requirements, if necessary. To do so:
On the Tools menu, select Project Settings.
Select the Type Mapping tab.
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:
(Optional) To convert dynamic or ad-hoc queries, right-click the node and select Add Statement.
Select the Connect to SQL Server tab.
- Enter connection details for your SQL Server instance.
- 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.
- Enter authentication details, and then select Connect.
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.
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.
Compare the converted Transact-SQL text to the original code, and review the recommendations.
In the output pane, select Review results and review the errors in the Error List pane.
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..
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.
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.
- Before you perform data migration on the server side, ensure that:
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:
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.
Review the mapping between your source project and your target.
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.
After migration is completed, view the Data Migration Report.
Connect to your SQL Server instance by using SQL Server Management Studio, and validate the migration by reviewing the data and schema.
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.
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.
The test approach for database migration consists of the following activities:
- 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.
- 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.
- Run validation tests: Run validation tests against the source and the target, and then analyze the results.
- Run performance tests: Run performance tests against the source and the target, and then analyze and compare the results.
The post-migration phase is crucial for reconciling any data accuracy issues, verifying completeness, and addressing performance issues with the workload.
For more information about these issues and the steps to mitigate them, see the Post-migration validation and optimization guide.
For more assistance with completing this migration scenario, see the following resource. It was developed in support of a real-world migration project engagement.
|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.
- To learn more about migrating MySQL databases to SQL Server, see SQL Server Migration Assistant documentation for MySQL.
- For a matrix of Microsoft and third-party services and tools that are available to assist you with various database and data migration scenarios and specialty tasks, see Services and tools for data migration.
- For other migration guides, see Azure Database Migration Guides.