MySQL in Azure

January 19, 2021
Tags: ,
Ikaria Greece by Anastasia Papachristopoulou

Cloud computing is becoming more and more famous among the IT circles and it is growing super fast. Industries are charmed by its flexible character and the avoidance of having their own infrastructure.
An easy solution that offers automation on every field and they can scale up depending on the needs of each user and company.

There are many Cloud providers, such as Oracle Cloud Infrastructure, Microsoft Azure, Amazon Web Services, etc…
In this article, we are going to see how to set up a MySQL Database instance on Microsoft Azure Cloud.

At this point, it is important to clarify that we are going to set up MySQL as a Service (PaaS).

So, before starting with the actual Database creation, we need:

  • An Azure subscription, you may create a free Azure account that offers for the first month a $200 credit and for the first year the most wanted services.
  • Have an available resource group.
  • Have specifically access for MySQL.

Let’s sign in to Azure portal, https://portal.azure.com/ and you should see a screen like the following:

Azure MySQL

We need to verify that we have the correct resources available for our subscription, in order to set up the MySQL DB:

  • From Azure Portal, go to Subscriptions
  • Then, on Development Services and choose Resource Provider
  • Scroll down and check if Microsoft.DBforMySQL is registered
Azure MySQL

If it is not registered, then click Register on the top left corner:

Azure MySQL

Once the registration is completed, we are ready for creating our DB.

Azure MySQL

To create the MySQL Database, we need to choose Azure Database for MySQL Servers:

Azure MySQL

By clicking the Add option on the top left, we are presented with two options, as it can be shown below:

Azure MySQL
  • Single Server is a fully managed database service with minimal requirements for customizations of the database. The single server platform is designed to handle most of the database management functions such as patching, backups, high availability, security with minimal user configuration and control. The architecture is optimized to provide 99.99% availability on single availability zone. Single servers are best suited for cloud native applications designed to handle automated patching without the need for granular control on the patching schedule and custom MySQL configuration settings. MySQL available version is 8.0.15
  • Flexible Server (Preview) is a fully managed database service designed to provide more granular control and flexibility over database management functions and configuration settings. In general, the service provides more flexibility and server configuration customizations compared to the single server deployment based on the user requirements. The flexible server architecture allows users to opt for high availability within a single availability zone and across multiple availability zones. Flexible servers also provide better cost optimization controls with the ability to start/stop your server and burstable SKUs, ideal for workloads that do not need full compute capacity continuously. MySQL version is 5.7 and 8.0.21 is on trial.

We choose Single Server for our start, and we are presented with the following screen:

Azure MySQL
Azure MySQL

We need to set accordingly:

Subscription: Make sure that you have choosen the corresponding subscription

Resource Group: Choose the proper resource group with the correct resources

Server name: This is actually the name of the MySQL Server

Data Source: You may create the new server from a Backup, here we choose none

Location: Choose the proper location that your resource group has access to

Version : Available versions 5.6,5.7 and 8.0

Compute+storage: Choose the best settings, we have Basic , General Purpose and Memory Optimized. The basic differences are among Basic & General Purpose/Memory Optimized.

Basic offers 2 cores and storage up to 1024GB.

General Purpose offers up to 64 cores and storage up to 16384GB.

Memory Optimized offers up to 32 cores and storage up to 16384GB.

All three available configurations offer Backup retention policy up to 35 days (default is 7 days).

General Purpose:

Azure MySQL
Azure MySQL
Azure MySQL
Azure MySQL
Azure MySQL

Admin username: Choose the proper name of the DB admin

Password and Confirm Password : Create a strong password for the DB admin

As soon as these settings are ready, we go to the Next:

Azure MySQL

Additional Settings:

We are able to select encryption:

Azure MySQL

And then moving on:

Azure MySQL

Tags : are name/value pairs that enable you to categorize and view consolidated billing by applying the same tag to multiple resources and resource groups. We won’t be organizing our resources with tags now so we are moving on to Review&Create to check the price and the options we have selected:

Azure MySQL

While our DB is being created, we see its progress:

Azure MySQL

Once ready, we are able to access the new resource that we created :

Azure MySQL

From this page, we may stop the server, reset the password , restore/delete and restart.

From the left side-bar, we may create alerts/metrics and to gather information.
The server logs are also available on this section, as well as the Replica option in case we need to set up a replica for our environment.

Azure MySQL

Same for the server settings:

Azure MySQL

One important note, before we connect officially to our Database.
We need to add the proper Firewall Rule to allow our Client to connect to the MySQL instance:

Azure MySQL

In order to connect to the Database via MySQL Workbench we need to use the Server name on the Hostname as well as the Username, like you may see on the following screenshot:

Azure MySQL

Finally, we are connected to the Database and we are able to execute any query we wish:

Azure MySQL

If you wish to delete the Database, Azure will give you a warning that the deletion is irreversible and you will need to provide MySQL Server’s name.

The same concept lies for the Flexible Server, but with a couple of differences:

Azure MySQL
Azure MySQL

Here, we need to specify the expected Workload type and based on that the most appropriate settings are being recommended and we also have Zone Redundancy available :

Azure MySQL

Backups offer the same retention policy as in Single Server:

Azure MySQL

To be able to connect, we need to set the Firewall Rules, either a specific Public address to access the Flexible MySQL Server or via a Virtual Network:

Azure MySQL
Azure MySQL

Flexible Servers offers synchronous replication when Zone Redundancy is enabled, however it does not offer read-only replicas and due to synchronous replication to another availability zone, primary database server can experience elevated write and commit latency.

We need to mention here that if a more updated version of MySQL is needed, then we will need to have a VM created.

Conclusion

Depending on your needs, Cloud computing can for sure serve them and most probably for a fair price. It offers a variety of services, so give it a try!

After all, it is no coincidence that our heads are up in the clouds.

References

https://www.mysql.com/

https://docs.microsoft.com/en-us/azure/mysql/select-right-deployment-type

https://docs.microsoft.com/en-us/azure/mysql/flexible-server/concepts-high-availability

One Response to “MySQL in Azure”

  1. […] until now we have seen MDS (MySQL Database Service) and MySQL in Azure. As the Cloud technology keeps moving fast, I thought it would be a good idea to see how to set up […]

Leave a Reply