Transfer a MySQL database to MSSQL Server
Use case: we receive data in MySQL and we need to move it to our SQL database server for data migration.
SQL Server Migration Assistant for MySQL (SSMA) is a great tool to achieve it and it is quite simple to use.
Link to download SSMA https://www.microsoft.com/en-us/download/details.aspx?id=54257
Prerequisites:
- MySQL ODBC driver is installed.
- An empty database in SQL server to import data to
From SQL Server Migration Assistant for MySQL windows, select New Project, please make sure to choose the right SQL server version of the server where we are migrating data to.
Next, we will configure connection for MySQL. Click on the button Connect to MySQL on the top of SSMA window and enter connection information. Note that the driver for MySQL needs to be installed in advance.
After successfully connect to MySQL, choose the database to export. Here I use ExportDemo as an example. Click OK to confirm the selection.
The system will load data from ExportDemo, verify to see if it shows all table you want to export.
Next step, connect to SQL server as below. it will take a while to load database objects.
After the system finishes loading, navigate to the right panel for the schema mapping. By default, SSMA maps source schema to the same name in SQL server. We need to modify it to map to dbo schema.
Click on Modify and change it as following:
Go back to SQL Metadata Explorer (the left bottom panel) to verify that there is no table and data under dbo schema in ImportDemo database
Gp to MySQL Metadata Explorer and select tables we want to migrate, then right click and select Convert Schema.
The system will create two tables in SQLMetadata Explorer.
However, they are not in database yet. We will need to right click on Tables and select Synchronize with Database to create those tables in SQL Server
SSMA will list out all tables will be synced from Local Metadata to database in SQL server. Click OK to start the sync. After this step, tables are created in SQL database and we can start migrating data.
Go back to MySQL Metadata Explorer, right click on Tables and select Migrate Data.
After finishes, SSMA will provide a report for data sync. Make sure the success rate is 100% for all tables.
Tada! All tables and data from MySQL are now in SQL Server and ready for the next steps.