Migrate MySQL Database To Azure Database For Mysql Online
Migrate MySQL Database To Azure Database For Mysql Online
for MySQL
Azure Database for MySQL is a relational database service in the Microsoft cloud based on
the MySQL Community Edition (available under the GPLv2 license) database engine, versions
5.6 and 5.7. Azure Database for MySQL delivers:
Dump and restore from the command-line (using mysqldump). On the source system
create a backup file from the command-line using mysqldump.:
mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
Now create a database on the target Azure Database for MySQL server. Create an empty
database on the target Azure Database for MySQL server where you want to migrate the
data. Use a tool such as MySQL Workbench, Toad, or Navicat to create the database.
Once you have created the target database, you can use the mysql command or MySQL
Workbench to restore the data into the specific newly created database from the dump
file.
mysql -h [hostname] -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]
https://docs.microsoft.com/en-us/azure/mysql/concepts-migrate-dump-restore
Table data export and import wizards from the object browser's context menu.
You can access these wizards from the object browser's context menu by right-clicking a table.
Then choose either Table Data Export Wizard or Table Data Import Wizard.
SQL data export and import wizards from the Navigator pane.
Connect to the source server using MySQL workbench. Then Click on the database you want to
Import/Export and click on the Administration Tab in the Navigator Panel.
Data Export:
1. Select each schema that you want to export, optionally choose specific schema objects/tables
from each schema, and generate the export. Configuration options include export to a project
folder or self-contained SQL file, dump stored routines and events, or skip table data.
Alternatively, use Export a Result Set to export a specific result set in the SQL editor to another
format, such as CSV, JSON, HTML, and XML.
2. Select the database objects to export, and configure the related options.
3. Click Refresh to load the current objects.
4. Optionally, open the Advanced Options tab to refine the export operation. For example, add
table locks, use replace instead of insert statements, and quote identifiers with backtick
characters.
5. Click Start Export to begin the export process.
Data Import
1. Choose the project folder or self-contained SQL file, choose the schema to import into, or
choose New to define a new schema.
2. Click Start Import to begin the import process.
https://docs.microsoft.com/en-us/azure/mysql/concepts-migrate-import-export
2. To import schema to Azure Database for MySQL target, run the following command:
3. If you have foreign keys in your schema, the initial load and continuous sync of the migration
will fail. Execute the following script in MySQL Workbench to extract the drop foreign key script
and add foreign key script.
4. Create a DMS instance. In the Azure portal, select + Create a resource, search for Azure
Database Migration Service, and then select Azure Database Migration Service . After the
service is created, locate it within the Azure portal, open it, and then create a new migration
project.
Once the datas are synced begin cut over procedures by stopping connection to source
database. Then wait till the target is fully synced then switch connections to the target database
https://docs.microsoft.com/en-us/azure/dms/tutorial-mysql-azure-mysql-online
Challenges faced:
Ensure that Source MySql server version is supported by Azure databases for Mysql
Ensure that foreign keys are dropped before starting the migration initial load.
Having foreign keys in the database schema causes the initial load and continuous
sync to fail. You can add the foreign key after completion.
Schema must match between source MySQL database and target database in Azure
Database for MySQL
Binary logging should be enabled in the source database. By default binary logging
option will be disabled during MySql server installation.
The user of the source database should have ReplicationAdmin role with the
privileges: REPLICATION CLIENT, REPLICATION REPLICA and SUPER if Mysql server
below 5.6.6
Disable all triggers if any in the target database before migration start. You can
enable trigger after migration is done.
The source MySQL Server version must be version 5.6.35, 5.7.18 or later
Same version migration. Migrating MySQL 5.6 to Azure Database for MySQL 5.7 isn't supported.
Collations defined for the source MySQL database are the same as the ones defined in target
Azure Database for MySQL.
Schema must match between source MySQL database and target database in Azure Database
for MySQL.
Schema in target Azure Database for MySQL must not have foreign keys.
Schema in target Azure Database for MySQL must not have any triggers.
Datatype limitations
Limitation: If there's a JSON datatype in the source MySQL database, migration will fail during
continuous sync. Workaround: Modify JSON datatype to medium text or longtext in source
MySQL database.
Limitation: If there's no primary key on tables, continuous sync will fail. Workaround:
Temporarily set a primary key for the table for migration to continue. You can remove the primary
key after data migration is complete.
LOB limitations
Large Object (LOB) columns are columns that could grow large in size. For MySQL, Medium text,
Longtext, Blob, Mediumblob, Longblob, etc. are some of the datatypes of LOB.
Limitation: If LOB data types are used as primary keys, migration will fail. Workaround: Replace
primary key with other datatypes or columns that aren't LOB.
Limitation: If the length of Large Object (LOB) column is bigger than 32 KB, data might be
truncated at the target. You can check the length of LOB column using this query: Workaround: If
you have LOB object that is bigger than 32 KB, contact engineering team at Ask Azure Database
Migrations
Other limitations
A password string that has opening and closing curly brackets { } at the beginning and end of the
password string isn't supported. This limitation applies to both connecting to source MySQL and
target Azure Database for MySQL.
In DMS, the limit of databases to migrate in one single migration activity is four.