Quickstart: Create an Azure Database for MySQL server by using the Azure portal
APPLIES TO: Azure Database for MySQL - Single Server
Azure Database for MySQL is a managed service that you use to run, manage, and scale highly available MySQL databases in the cloud. This quickstart shows you how to use the Azure portal to create an Azure Database for MySQL single server. It also shows you how to connect to the server.
An Azure subscription is required. If you don't have an Azure subscription, create a free Azure account before you begin.
Create an Azure Database for MySQL single server
Go to the Azure portal to create a MySQL Single Server database. Search for and select Azure Database for MySQL:
On the Select Azure Database for MySQL deployment option page, select Single server:
Enter the basic settings for a new single server:
Setting Suggested value Description Subscription Your subscription Select the desired Azure subscription. Resource group myresourcegroup Enter a new resource group or an existing one from your subscription. Server name mydemoserver Enter a unique name. The server name can contain only lowercase letters, numbers, and the hyphen (-) character. It must contain 3 to 63 characters. Data source None Select None to create a new server from scratch. Select Backup only if you're restoring from a geo-backup of an existing server. Location Your desired location Select a location from the list. Version The latest major version Use the latest major version. See all supported versions. Compute + storage Use the defaults The default pricing tier is General Purpose with 4 vCores and 100 GB storage. Backup retention is set to 7 days, with the Geographically Redundant backup option.
Review the pricing page, and update the defaults if you need to.
Admin username mydemoadmin Enter your server admin user name. You can't use azure_superuser, admin, administrator, root, guest, or public for the admin user name. Password A password A new password for the server admin user. The password must be 8 to 128 characters long and contain a combination of uppercase or lowercase letters, numbers, and non-alphanumeric characters (!, $, #, %, and so on).
Consider using the Basic pricing tier if light compute and I/O are adequate for your workload. Note that servers created in the Basic pricing tier can't later be scaled to General Purpose or Memory Optimized.
Select Review + create to provision the server.
Wait for the portal page to display Your deployment is complete. Select Go to resource to go to the newly created server page:
Configure a server-level firewall rule
By default, the new server is protected with a firewall. To connect, you must provide access to your IP by completing these steps:
Go to Connection security from the left pane for your server resource. If you don't know how to find your resource, see How to open a resource.
Select Add current client IP address, and then select Save.
To avoid connectivity problems, check if your network allows outbound traffic over port 3306, which is used by Azure Database for MySQL.
You can add more IPs or provide an IP range to connect to your server from those IPs. For more information, see How to manage firewall rules on an Azure Database for MySQL server.
Connect to the server by using mysql.exe
Open Azure Cloud Shell in the portal by selecting the first button on the toolbar, as shown in the following screenshot. Note the server name, server admin name, and subscription for your new server in the Overview section, as shown in the screenshot.
If you're opening Cloud Shell for the first time, you'll be prompted to create a resource group and storage account. This is a one-time step. It will be automatically attached for all sessions.
Run the following command in the Azure Cloud Shell terminal. Replace the values shown here with your actual server name and admin user name. For Azure Database for MySQL, you need to add
@\<servername>to the admin user name, as shown here:
mysql --host=mydemoserver.mysql.database.azure.com --user=myadmin@mydemoserver -p
Here's what it looks like in the Cloud Shell terminal:
Requesting a Cloud Shell.Succeeded. Connecting terminal... Welcome to Azure Cloud Shell Type "az" to use Azure CLI Type "help" to learn about Cloud Shell user@Azure:~$mysql -h mydemoserver.mysql.database.azure.com -u myadmin@mydemoserver -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 64796 Server version: 126.96.36.199 Source distribution Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
In the same Azure Cloud Shell terminal, create a database named
mysql> CREATE DATABASE guest; Query OK, 1 row affected (0.27 sec)
Switch to the
mysql> USE guest; Database changed
quit, and then select Enter to quit mysql.
Clean up resources
You have now created an Azure Database for MySQL server in a resource group. If you don't expect to need these resources in the future, you can delete them by deleting the resource group, or you can just delete the MySQL server. To delete the resource group, complete these steps:
- In the Azure portal, search for and select Resource groups.
- In the list of resource groups, select the name of your resource group.
- On the Overview page for your resource group, select Delete resource group.
- In the confirmation dialog box, type the name of your resource group, and then select Delete.
To delete the server, you can select Delete on the Overview page for your server, as shown here:
Submit and view feedback for