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:
- An Azure subscription. If you don't have one, create a free account.
- Azure CLI installed (optional, but recommended for automation). Install Azure CLI.
Steps to Create Your First Azure Database for MySQL Server
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.
- Sign in to the Azure portal.
- In the search bar at the top, type "Azure Database for MySQL servers" and select it.
- Click + Create.
- Select the Single server deployment option.
- 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.
- Click Review + create, then Create. Deployment may take a few minutes.
Once deployed, you'll find your server in the Azure portal.
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.
- Navigate to your newly created Azure Database for MySQL server resource in the Azure portal.
- Under Settings, select Connection security.
- Click Add current client IP address to add your current public IP address to the firewall rules.
- You can also set up Allow access to Azure services to enable other Azure resources to connect to your server.
- Click Save.
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)
- Download and install MySQL Workbench if you haven't already.
- Open MySQL Workbench and click the '+' icon to set up a new connection.
- 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.
- Connection Name: A descriptive name (e.g.,
- Click Test Connection to verify.
- Click OK to save the connection.
- 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.
Next Steps
Congratulations! You've successfully created and connected to your Azure Database for MySQL server. Here are some recommended next steps:
- Create a database within your server.
- Configure performance options like vCores and storage.
- Learn about backup and restore strategies.
- Explore connection pooling for application efficiency.