Skip to content

Commit d7e3127

Browse files
authored
Merge pull request #159331 from HJToland3/localworking
Localworking - RDS MySQL
2 parents 1288ef9 + 69a6cbb commit d7e3127

22 files changed

+279
-0
lines changed

articles/mysql/TOC.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@
556556
- name: Migrate data with MySQL Workbench
557557
href: concepts-migrate-import-export.md
558558
displayName: import , migrate, export
559+
- name: Migrate RDS MySQL data with MySQL Workbench
560+
href: how-to-migrate-rds-mysql-workbench.md
561+
displayName: import , migrate, export
559562
- name: Minimal downtime migration with DMS
560563
href: howto-migrate-online.md
561564
displayName: migrate, dms, database migration service
Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
---
2+
title: Migrate Amazon RDS for MySQL to Azure Database for MySQL using the MySQL Workbench
3+
description: This article describes how to migrate Amazon RDS for MySQL to Azure Database for MySQL by using the MySQL Workbench Migration Wizard.
4+
author: HJToland3
5+
ms.author: pariks
6+
ms.service: mysql
7+
ms.topic: how-to
8+
ms.date: 05/20/2021
9+
---
10+
11+
# Migrate Amazon RDS for MySQL to Azure Database for MySQL using the MySQL Workbench
12+
13+
You can use various utilities, such as MySQL Workbench Export/Import, Azure Database Migration Service (DMS), and MySQL dump and restore, to migrate Amazon RDS for MySQL to Azure Database for MySQL. However, using the MySQL Workbench Migration Wizard provides an easy and convenient way to move your Amazon RDS for MySQL databases to Azure Database for MySQL.
14+
15+
With the Migration Wizard, you can conveniently select which schemas and objects to migrate. It also allows you to view server logs to identify errors and bottlenecks in real time. As a result, you can edit and modify tables or database structures and objects during the migration process when an error is detected, and then resume migration without having to restart from scratch.
16+
17+
> [!NOTE]
18+
> You can also use the Migration Wizard to migrate other sources, such as Microsoft SQL Server, Oracle, PostgreSQL, MariaDB, etc., which are outside the scope of this article.
19+
20+
## Prerequisites
21+
22+
Before you start the migration process, it's recommended that you ensure that several parameters and features are configured and set up properly, as described below.
23+
24+
- Make sure the Character set of the source and target databases are the same.
25+
- Set the wait timeout to a reasonable time depending on the amount data or workload you want to import or migrate.
26+
- Set the `max_allowed_packet parameter` to a reasonable amount depending on the size of the database you want to import or migrate.
27+
- Verify that all of your tables use InnoDB, as Azure Database for MySQL Server only supports the InnoDB Storage engine.
28+
- Remove, replace, or modify all triggers, stored procedures, and other functions containing root user or super user definers (Azure Database for MySQL doesn’t support the Super user privilege). To replace the definers with the name of the admin user that is running the import process, run the following command:
29+
30+
```
31+
DELIMITER; ;/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`127.0.0.1`*/ /*!50003
32+
DELIMITER;
33+
/* Modified to */
34+
DELIMITER;
35+
/*!50003 CREATE*//*!50017 DEFINER=`AdminUserName`@`ServerName`*/ /*!50003
36+
DELIMITER;
37+
38+
```
39+
40+
- If User Defined Functions (UDFs) are running on your database server, you need to delete the privilege for the mysql database. To determine if any UDFs are running on your server, use the following query:
41+
42+
```
43+
SELECT * FROM mysql.func;
44+
```
45+
46+
If you discover that UDFs are running, you can drop the UDFs by using the following query:
47+
48+
```
49+
DROP FUNCTION your_UDFunction;
50+
```
51+
52+
- Make sure that the server on which the tool is running, and ultimately the export location, has ample disk space and compute power (vCores, CPU, and Memory) to perform the export operation, especially when exporting a very large database.
53+
- Create a path between the on-premises or AWS instance and Azure Database for MySQL if the workload is behind firewalls or other network security layers.
54+
55+
## Begin the migration process
56+
57+
1. To start the migration process, sign in to MySQL Workbench, and then select the home icon.
58+
2. In the left-hand navigation bar, select the Migration Wizard icon, as shown in the screenshot below.
59+
60+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/begin-the-migration.png" alt-text="MySQL Workbench start screen":::
61+
62+
The **Overview** page of the Migration Wizard is displayed, as shown below.
63+
64+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/migration-wizard-welcome.png" alt-text="MySQL Workbench Migration Wizard welcome page":::
65+
66+
3. Determine if you have an ODBC driver for MySQL Server installed by selecting **Open ODBC Administrator**.
67+
68+
In our case, on the **Drivers** tab, you’ll notice that there are already two MySQL Server ODBC drivers installed.
69+
70+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/obdc-administrator-page.png" alt-text="ODBC Data Source Administrator page":::
71+
72+
If a MySQL ODBC driver isn't installed, use the MySQL Installer you used to install MySQL Workbench to install the driver. For more information about MySQL ODBC driver installation, see the following resources:
73+
74+
- [MySQL :: MySQL Connector/ODBC Developer Guide :: 4.1 Installing Connector/ODBC on Windows](https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-installation-binary-windows.html)
75+
- [ODBC Driver for MySQL: How to Install and Set up Connection (Step-by-step) – {coding}Sight (codingsight.com)](https://codingsight.com/install-and-configure-odbc-drivers-for-mysql/)
76+
77+
4. Close the **ODBC Data Source Administrator** dialog box, and then continue with the migration process.
78+
79+
## Configure source database server connection parameters
80+
81+
1. On the **Overview** page, select **Start Migration**.
82+
83+
The **Source Selection** page appears. Use this page to provide information about the RDBMS you're migrating from and the parameters for the connection.
84+
85+
2. In the **Database System** field, select **MySQL**.
86+
3. In the **Stored Connection** field, select one of the saved connection settings for that RDBMS.
87+
88+
You can save connections by marking the checkbox at the bottom of the page and providing a name of your preference.
89+
90+
4. In the **Connection Method** field, select **Standard TCP/IP**.
91+
5. In the **Hostname** field, specify the name of your source database server.
92+
6. In the **Port** field, specify **3306**, and then enter the username and password for connecting to the server.
93+
7. In the **Database** field, enter the name of the database you want to migrate if you know it; otherwise leave this field blank.
94+
8. Select **Test Connection** to check the connection to your MySQL Server instance.
95+
96+
If you’ve entered the correct parameters, a message appears indicating a successful connection attempt.
97+
98+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/source-connection-parameters.png" alt-text="Source database connection parameters page":::
99+
100+
9. Select **Next**.
101+
102+
## Configure target database server connection parameters
103+
104+
1. On the **Target Selection** page, set the parameters to connect to your target MySQL Server instance using a process similar to that for setting up the connection to the source server.
105+
2. To verify a successful connection, select **Test Connection**.
106+
107+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/target-connection-parameters.png" alt-text="Target database connection parameters page":::
108+
109+
3. Select **Next**.
110+
111+
## Select the schemas to migrate
112+
113+
The Migration Wizard will communicate to your MySQL Server instance and fetch a list of schemas from the source server.
114+
115+
1. Select **Show logs** to view this operation.
116+
117+
The screenshot below shows how the schemas are being retrieved from the source database server.
118+
119+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/retrieve-schemas.png" alt-text="Fetch schemas list page":::
120+
121+
2. Select **Next** to verify that all the schemas were successfully fetched.
122+
123+
The screenshot below shows the list of fetched schemas.
124+
125+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/schemas-selection.png" alt-text="Schemas selection page":::
126+
127+
You can only migrate schemas that appear in this list.
128+
129+
3. Select the schemas that you want to migrate, and then select **Next**.
130+
131+
## Object migration
132+
133+
Next, specify the object(s) that you want to migrate.
134+
135+
1. Select **Show Selection**, and then, under **Available Objects**, select and add the objects that you want to migrate.
136+
137+
When you've added the objects, they'll appear under **Objects to Migrate**, as shown in the screenshot below.
138+
139+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/source-objects.png" alt-text="Source objects selection page":::
140+
141+
In this scenario, we’ve selected all table objects.
142+
143+
2. Select **Next**.
144+
145+
## Edit data
146+
147+
In this section, you have the option of editing the objects that you want to migrate.
148+
149+
1. On the **Manual Editing** page, notice the **View** drop-down menu in the top-right corner.
150+
151+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/manual-editing.png" alt-text="Manual Editing selection page":::
152+
153+
The **View** drop-down box includes three items:
154+
155+
- **All Objects** – Displays all objects. With this option, you can manually edit the generated SQL before applying them to the target database server. To do this, select the object and select Show Code and Messages. You can see (and edit!) the generated MySQL code that corresponds to the selected object.
156+
- **Migration problems** – Displays any problems that occurred during the migration, which you can review and verify.
157+
- **Column Mapping** – Displays column mapping information. You can use this view to edit the name and change column of the target object.
158+
159+
2. Select **Next**.
160+
161+
## Create the target database
162+
163+
1. Select the **Create schema in target RDBMS** check box.
164+
165+
You can also choose to keep already existing schemas, so they won't be modified or updated.
166+
167+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/create-target-database.png" alt-text="Target Creation Options page":::
168+
169+
In this article, we've chosen to create the schema in target RDBMS, but you can also select the **Create a SQL script file** check box to save the file on your local computer or for other purposes.
170+
171+
2. Select **Next**.
172+
173+
## Run the MySQL script to create the database objects
174+
175+
Since we've elected to create schema in the target RDBMS, the migrated SQL script will be executed in the target MySQL server. You can view its progress as shown in the screenshot below:
176+
177+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/create-schemas.png" alt-text="Create Schemas page":::
178+
179+
1. After the creation of the schemas and their objects completes, select **Next**.
180+
181+
On the **Create Target Results** page, you’re presented with a list of the objects created and notification of any errors that were encountered while creating them, as shown in the following screenshot.
182+
183+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/create-target-results.png" alt-text="Create Target Results page":::
184+
185+
2. Review the detail on this page to verify that everything completed as intended.
186+
187+
For this article, we don’t have any errors. If there's no need to address any error messages, you can edit the migration script.
188+
189+
3. In the **Object** box, select the object that you want to edit.
190+
4. Under **SQL CREATE script for selected object**, modify your SQL script, and then select **Apply** to save the changes.
191+
5. Select **Recreate Objects** to run the script including your changes.
192+
193+
If the script fails, you may need to edit the generated script. You can then manually fix the SQL script and run everything again. In this article, we’re not changing anything, so we’ll leave the script as it is.
194+
195+
6. Select **Next**.
196+
197+
## Transfer data
198+
199+
This part of the process moves data from the source MySQL Server database instance into your newly created target MySQL database instance. Use the **Data Transfer Setup** page to configure this process.
200+
201+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/data-transfer-setup.png" alt-text="Data Transfer Setup page":::
202+
203+
This page provides options for setting up the data transfer. For the purposes of this article, we’ll accept the default values.
204+
205+
1. To begin the actual process of transferring data, select **Next**.
206+
207+
The progress of the data transfer process appears as shown in the following screenshot.
208+
209+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/bulk-data-transfer.png" alt-text="Bulk Data Transfer page":::
210+
211+
Note that the data transfer process will take a little time to complete.
212+
213+
2. After the transfer completes, select **Next**.
214+
215+
The **Migration Report** page appears, providing a report summarizing the whole process, as shown on the screenshot below:
216+
217+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/migration-report.png" alt-text="Migration Progress Report page":::
218+
219+
3. Select **Finish** to close the Migration Wizard.
220+
221+
The migration is now successfully completed.
222+
223+
## Verify consistency of the migrated schemas and tables
224+
225+
1. Next, log into your MySQL target database instance to verify that the migrated schemas and tables are consistent with your MySQL source database.
226+
227+
In our case, you can see that all schemas (sakila, moda, items, customer, clothes, world, and world_x) from the Amazon RDS for MySQL: **MyjolieDB** database have been successfully migrated to the Azure Database for MySQL: **azmysql** instance.
228+
229+
2. To verify the table and rows counts, run the following query on both instances:
230+
231+
`SELECT COUNT (*) FROM sakila.actor;`
232+
233+
You can see from the screenshot below that the row count for Amazon RDS MySQL is 200, which matches the Azure Database for MySQL instance.
234+
235+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/table-row-size-source.png" alt-text="Table and Row size source database":::
236+
237+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/table-row-size-target.png" alt-text="Table and Row size target database":::
238+
239+
While you can run the above query on every single schema and table, that will be quite a bit of work if you’re dealing with hundreds of thousands or even millions of tables. You can use the queries below to verify the schema (database) and table size instead.
240+
241+
3. To check the database size, run the following query:
242+
243+
```
244+
SELECT table_schema AS "Database",
245+
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
246+
FROM information_schema.TABLES
247+
GROUP BY table_schema;
248+
```
249+
250+
4. To check the table size, run the following query:
251+
252+
```
253+
SELECT table_name AS "Table",
254+
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
255+
FROM information_schema.TABLES
256+
WHERE table_schema = "database_name"
257+
ORDER BY (data_length + index_length) DESC;
258+
```
259+
260+
You see from the screenshots below that schema (database) size from the Source Amazon RDS MySQL instance is the same as that of the target Azure Database for MySQL Instance.
261+
262+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/database-size-source.png" alt-text="Database size source database":::
263+
264+
:::image type="content" source="./media/how-to-migrate-rds-mysql-workbench/database-size-target.png" alt-text="Database size target database":::
265+
266+
Since the schema (database) sizes are the same in both instances, it's not really necessary to check individual table sizes. In any case, you can always use the above query to check your table sizes, as necessary.
267+
268+
You’ve now confirmed that your migration completed successfully.
269+
270+
## Next steps
271+
272+
- For more information about migrating databases to Azure Database for MySQL, see the [Database Migration Guide](https://github.com/Azure/azure-mysql/tree/master/MigrationGuide).
273+
- View the video [Easily migrate MySQL/PostgreSQL apps to Azure managed service](https://medius.studios.ms/Embed/Video/THR2201?sid=THR2201), which contains a demo showing how to migrate MySQL apps to Azure Database for MySQL.
180 KB
Loading
83.8 KB
Loading
130 KB
Loading
104 KB
Loading
65 KB
Loading
275 KB
Loading
58.1 KB
Loading
58 KB
Loading

0 commit comments

Comments
 (0)