Hosting MySQL on Azure made easy

Armaghan Shakir
3 min readDec 27, 2023

--

Azure + MySQL

In this article you will learn the easiest method to host MySQL flexible database on Microsoft Azure

Make sure you have a Microsoft Azure account and have created a resource. If you haven’t created a resource yet, you can follow this guide to create one. And you are good to proceed.

  1. Navigate to the Azure Portal, click on the side panel, and select ‘All services.’

2. In Categories select “Databases”

You can see there are multiple options for SQL on Azure. Each service has its own pros and cons, used for different use-cases and some services depend on each other as well.

Scroll down and select the service by the name, “Azure Database for MySQL servers”

Click “Create” to create a new instance

Click “Create” on Flexible Server

In “Basics” tab, select subscription plan, resource, server name, region and create username and password. Select “MySQL authentication only” in Authentication method.

In “Networking” tab, select “Public access” in “Connectivity method”. Allow all IP Addresses in Firewall rules.

Keep all the other options as default and click “Create”. It will take some time to review and initialize the deployment.

Go to the resource

By default SSL is enforced, to keep things easier, we will turn it off.

From the left panel, select “Server parameters”

Search “require_secure_transport”, turn it OFF and Save it.

Leave that page and head back to MySQL service and go to “Connect” from the left panel. Here you will find the details to build a connection in code.

Copy the connection details and use them in you code, for example in python

import mysql.connector

connection = mysql.connector.connect(
host=HOSTNAME,
port=PORT,
user=USERNAME,
password=PASSWROD,
database=DB_NAME
)
cursor = connection.cursor()

You can also connect to the sql server in Azure Cloud Shell from the “Connect” button on top in overview tab

--

--