Create an Azure Database for MySQL Server

This article guides you through the process of creating an Azure Database for MySQL server. You can choose to create a server using the Azure portal, Azure CLI, or an ARM template. Each method offers a streamlined experience for setting up your MySQL instance in Azure.

Note: Before you begin, ensure you have an active Azure subscription. If you don't have one, you can create a free account.

Methods for Creating a Server

Azure Database for MySQL offers flexible options for server creation to suit your workflow:

1. Using the Azure Portal

The Azure portal provides a graphical interface for creating and managing your Azure resources. It's the most common and intuitive method for many users.

Steps:

  1. Sign in to the Azure portal.
  2. Click Create a resource in the top-left corner.
  3. In the search bar, type "Azure Database for MySQL" and select it from the results.
  4. Click Create.
  5. On the Basics tab, select your Subscription, Resource group, Server name, Location, and Version.
  6. Choose a Compute + storage option that fits your needs.
  7. Configure Networking, Security, and Tags as required.
  8. Review the settings and click Create.

For detailed instructions, refer to the Azure portal creation guide.

2. Using the Azure CLI

The Azure Command-Line Interface (CLI) is a powerful tool for automating resource deployment and management. It's ideal for scripting and continuous integration/continuous deployment (CI/CD) pipelines.

To create a server using the Azure CLI, you'll use the az mysql server create command.


az group create --name MyResourceGroup --location eastus
az mysql server create --resource-group MyResourceGroup --name mydemoserver --admin-user myadmin --admin-password  --sku-name B_Gen5_1 --version 5.7
                

Replace <your-password> with a strong password for your admin user.

For comprehensive command options and examples, see the Azure CLI creation guide.

3. Using an ARM Template

Azure Resource Manager (ARM) templates allow you to define your infrastructure as code, enabling repeatable and consistent deployments.

You can find sample ARM templates for creating Azure Database for MySQL servers in the Azure Quickstart Templates repository. A basic template would define parameters for resource group, server name, admin credentials, and SKU.

Example snippet from an ARM template:


{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "serverName": {
            "type": "string",
            "metadata": {
                "description": "Name of the Azure Database for MySQL server."
            }
        },
        "adminLogin": {
            "type": "string",
            "metadata": {
                "description": "Login name for the server admin."
            }
        },
        "adminPassword": {
            "type": "securestring",
            "metadata": {
                "description": "Password for the server admin."
            }
        }
        // ... other parameters like location, sku, version
    },
    "resources": [
        {
            "type": "Microsoft.DBforMySQL/servers",
            "apiVersion": "2017-12-01",
            "location": "[parameters('location')]",
            "name": "[parameters('serverName')]",
            "sku": {
                "name": "[parameters('sku')]",
                "tier": "[parameters('tier')]",
                "capacity": "[parameters('capacity')]"
            },
            "properties": {
                "adminLogin": "[parameters('adminLogin')]",
                "adminPassword": "[parameters('adminPassword')]"
                // ... other properties
            }
        }
    ]
}
                

Learn more about creating servers with ARM templates in the dedicated ARM template guide.

Important Considerations:

  • Server Name Uniqueness: Server names must be globally unique across Azure.
  • Region Selection: Choose a region close to your applications or users for optimal performance.
  • Pricing Tiers: Select the appropriate pricing tier (Basic, General Purpose, Memory Optimized) based on your workload requirements.
  • Firewall Rules: Configure firewall rules to control access to your server.