>> Learn how to migrate your MySQL database to Azure
in this episode of Azure Tips and Tricks.
I'm going to migrate
my existing MySQL database to an Azure database for MySQL.
There are many ways to do that,
and I'll use MySQL Workbench to do it.
To follow along, you need
an existing MySQL database that can be accessed from Azure.
If you don't have one,
you can create a MySQL server in
an Azure VM and run a SQL script with sample data,
which you can find in the description of this video.
You'll also need to install MySQL Workbench in
a place that can access your existing database and Azure.
I'll start by creating an Azure Database for
MySQL server in the Azure portal.
Here it is, Create it.
First, I'll select Single server, that's fine.
Now select a Resource group,
and next, fill in a server name.
Here I'll put in a username for the server,
and now also a password for it.
Finally, confirm the password like this,
and let's create it.
I'll skip to when it is done.
Here is the Azure Database for MySQL.
Before I can migrate data to it,
I need to make sure that I can access it.
Let's see here, this looks good.
I don't deny public network access and the
allow access to Azure services setting is enabled.
You might also need to add
your IP address to the firewall before it works for you.
Here I am in MySQL Workbench.
This is running on my local machine,
which is connected to
my Azure subscription with an Azure express route connection.
Wherever your MySQL database is located,
you need to make sure that it can connect to Azure.
Let's connect to MySQL database,
here we go, this is the schema of the database.
Let's take a look at the tables and this one here,
there are lots of rows in the table, cool.
In here, you can go to Database and Migration Wizard.
I can use this wizard to migrate my data. Let's start.
First, this is my source database, my existing MySQL.
Next, now let's add my Azure MySQL as a new connection.
This is the host name for it,
which you can find in the Connection string blade
of the server in the Azure portal.
Now for the username,
and here, I'll put in the password. Here we go.
Let's test the connection,
cool, that worked and close it.
So now we have the source and target.
Next, now it will check the schema.
Next, and here I will pick the schema to migrate this one.
Next, another check here,
and all is well.
Next, let's see.
I want to only migrate my tables and not my views, cool.
Next, now it will create the SQL scripts for migration.
Next, and this looks good as well;
no warnings or errors.
Next one, I want to create the schema in the target Azure server,
and next, here it goes creating the schema,
and the next one.
Let's see, this looks good,
everything seems to work.
Here we go, I'll choose to do an online migration.
I can also create a batch file or
script to migrate the data later.
Let's do it. Here it goes, migrating the data.
All right, that's it, let's see.
That seems to have worked,
cool, let's try it out.
I'll connect to the Azure database server, here we go.
Here is the schema that is migrated and
these are the tables, let's query it.
Here are the rows of data that we migrated; that worked.
When you migrate your MySQL database to Azure,
you let Azure take care of running
your database and making it highly available, secure,
scalable and performant, so that you can
focus on building applications that add value.
There are several options to migrate the MySQL database to Azure,
and in this video,
we saw one of them.
You can use the Azure Database Migration Guide
at this URL to choose the right option for you.
Go and check it out.