Azure Database for MySQL

Quickstart Guide: Get your managed MySQL server up and running in minutes.

Welcome to Azure Database for MySQL

This guide will walk you through the essential steps to create and connect to your first Azure Database for MySQL server. Azure Database for MySQL provides fully managed database service that enables you to run, manage, and scale relational applications on Azure. Leveraging the community edition of MySQL, it offers high availability and elastic scalability.

Prerequisites

Before you begin, ensure you have the following:

Steps to Create Your First Azure Database for MySQL Server

1

Create an Azure Database for MySQL server

You can create a server using the Azure portal, Azure CLI, or ARM templates. We'll use the Azure portal for this quickstart.

  1. Sign in to the Azure portal.
  2. In the search bar at the top, type "Azure Database for MySQL servers" and select it.
  3. Click + Create.
  4. Select the Single server deployment option.
  5. Fill out the Basics tab:
    • Subscription: Choose your subscription.
    • Resource group: Create a new one or select an existing.
    • Server name: Enter a unique name (e.g., my-azure-mysql-server-123).
    • Region: Select a region close to you.
    • Version: Choose MySQL 5.7 or 8.0.
    • Compute + storage: Select the General Purpose or Memory Optimized tier based on your needs. For this quickstart, a basic configuration will suffice.
    • Admin username: Enter an administrator username (e.g., azureuser).
    • Password: Enter a strong password and confirm it.
  6. Click Review + create, then Create. Deployment may take a few minutes.

Once deployed, you'll find your server in the Azure portal.

2

Configure Server Firewall Rules

By default, Azure Database for MySQL is protected by a firewall. You need to configure rules to allow connections from your IP address or from other Azure services.

  1. Navigate to your newly created Azure Database for MySQL server resource in the Azure portal.
  2. Under Settings, select Connection security.
  3. Click Add current client IP address to add your current public IP address to the firewall rules.
  4. You can also set up Allow access to Azure services to enable other Azure resources to connect to your server.
  5. Click Save.
Security Note: It's recommended to restrict firewall rules to only necessary IP addresses or ranges to enhance security. Avoid using "0.0.0.0" unless absolutely required and understood.
3

Connect to Your Server

You can connect to your Azure Database for MySQL server using various tools, such as MySQL Workbench, the command-line client, or programming language connectors.

Using MySQL Workbench (GUI Tool)

  1. Download and install MySQL Workbench if you haven't already.
  2. Open MySQL Workbench and click the '+' icon to set up a new connection.
  3. Configure the connection settings:
    • Connection Name: A descriptive name (e.g., My Azure MySQL).
    • Hostname: Your server name from the Azure portal (e.g., my-azure-mysql-server-123.mysql.database.azure.com).
    • Port: 3306 (default MySQL port).
    • Username: The admin username you created (e.g., azureuser).
    • Click Store in Vault... and enter your password.
  4. Click Test Connection to verify.
  5. Click OK to save the connection.
  6. Double-click the saved connection to open the MySQL session.

Using the MySQL Command-Line Client

Ensure you have the MySQL client installed and your IP address is allowed by the firewall.

mysql -h <your-server-name>.mysql.database.azure.com -u <your-admin-username> -p

You will be prompted to enter your password.

Tip: You can find your server name and admin username on the Overview page of your Azure Database for MySQL server in the Azure portal.

Next Steps

Congratulations! You've successfully created and connected to your Azure Database for MySQL server. Here are some recommended next steps:

Explore More Azure Database for MySQL Documentation