快速入门:在 Azure 门户中创建 Azure Database for MySQL 服务器Quickstart: Create an Azure Database for MySQL server in the Azure portal

备注

将要查看的是 Azure Database for MySQL 的新服务。You are viewing the new service of Azure Database for MySQL. 若要查看经典 MySQL Database for Azure 的文档,请访问此页To view the documentation for classic MySQL Database for Azure, please visit this page.

Azure Database for MySQL 是一种托管服务,可用于在云中运行、管理和缩放高可用性的 MySQL 数据库。Azure Database for MySQL is a managed service that you use to run, manage, and scale highly available MySQL Databases in the cloud. 此快速入门介绍如何使用 Azure 门户在大约五分钟内创建 Azure Database for MySQL 服务器。This Quickstart shows you how to create an Azure Database for MySQL server in about five minutes using the Azure portal.

如果没有 Azure 订阅,请在开始前创建一个试用 Azure 帐户If you don't have an Azure subscription, create a trial Azure account before you begin.

登录到 Azure 门户Sign in to the Azure portal

打开 Web 浏览器,然后访问 Azure 门户Open your web browser, and then go to the Azure portal. 输入登录到门户所需的凭据。Enter your credentials to sign in to the portal. 默认视图是服务仪表板。The default view is your service dashboard.

创建 Azure Database for MySQL 服务器Create an Azure Database for MySQL server

创建 Azure Database for MySQL 服务器时,请使用定义好的一组计算和存储资源You create an Azure Database for MySQL server with a defined set of compute and storage resources. 请在 Azure 资源组中创建该服务器。You create the server within an Azure resource group.

按照以下步骤创建 Azure Database for MySQL 服务器:Follow these steps to create an Azure Database for MySQL server:

  1. 在门户左上角选择“创建资源” (+)。Select Create a resource (+) in the upper-left corner of the portal.

  2. 选择“数据库” > “Azure Database for MySQL”。Select Databases > Azure Database for MySQL. 还可以在搜索框中输入“MySQL” 以查找该服务。You can also enter MySQL in the search box to find the service.

Azure Database for MySQL 选项Azure Database for MySQL option

  1. 使用以下信息填写“新服务器详细信息”窗体:Fill out the new server details form with the following information:

“创建服务器”窗体Create server form

设置Setting 建议的值Suggested value 字段说明Field description
订阅Subscription 订阅Your subscription 选择要用于服务器的 Azure 订阅。Select the Azure subscription that you want to use for your server. 如果有多个订阅,请选择要计费的资源所在的订阅。If you have multiple subscriptions, choose the subscription in which you get billed for the resource.
资源组Resource group myresourcegroupmyresourcegroup 提供新的或现有的资源组名称。Provide a new or existing resource group name. 可以使用资源组来组织属于单个项目的依赖项。Resource group can be used organize your dependencies that belong to single project.
服务器名称Server name 唯一的服务器名称Unique server name 输入用于标识 Azure Database for MySQL 服务器的唯一名称。Enter a unique name that identifies your Azure Database for MySQL server. 例如,“mysqldbserver”。服务器名称只能包含小写字母、数字和连字符 (-) 字符。For example, 'mysqldbserver'.The server name can contain only lowercase letters, numbers, and the hyphen (-) character. 必须包含 3 到 63 个字符。It must contain from 3 to 63 characters.
数据源Data source None 选择“无”,从头开始创建新的服务器。Select None to create a new server from scratch. (如果是从现有 Azure Database for MySQL 服务器的异地备份创建服务器,则会选择“备份”)。(You would select Backup if you were creating a server from a geo-backup of an existing Azure Database for MySQL server).
服务器管理员登录名Server admin login myadminmyadmin 输入服务器管理员的用户名。Enter a username for your server administrator. 不能将“azure_superuser”、“admin”、“administrator”、“root”、“guest”或“public”用作管理员用户名 。You cannot use azure_superuser, admin, administrator, root, guest, or public as the admin username.
密码Password 由用户决定Your choice 为服务器管理员帐户提供新密码。Provide a new password for the server admin account. 密码长度必须为 8 到 128 个字符,并包含大写字母或小写字母、数字和非字母数字字符(!、$、#、% 等)的组合。Password must be 8 to 128 characters in length with a combination of uppercase or lowercase letters, numbers, and non-alphanumeric characters (!, $, #, %, and so on).
确认密码Confirm password 由用户决定Your choice 确认管理员帐户密码。Confirm the admin account password.
位置Location 离用户最近的区域The region closest to your users 选择最靠近用户或其他 Azure 应用程序的位置。Choose the location that is closest to your users or your other Azure applications.
版本Version 最新主版本The latest major version 最新主版本(除非你有需要其他版本的特定需求)。The latest major version (unless you have specific requirements that require another version).
计算 + 存储Compute + Storage 常规用途第 5 代2 vCore5 GB7 天异地冗余General Purpose, Gen 5, 2 vCores, 5 GB, 7 days, Geographically Redundant 新服务器的计算、存储和备份配置。The compute, storage, and backup configurations for your new server. 选择“配置服务器”。Select Configure server. 接下来,选择适当的定价层,有关详细信息,请参阅定价页面Next, select the appropriate pricing tier, for more information, see the pricing page. 若要在异地冗余存储中启用服务器备份,请从备份冗余选项中选择“异地冗余”。To enable your server backups in geo-redundant storage, select Geographically Redundant from the Backup Redundancy Options. 选择“确定”。Select OK.

备注

如果轻量级计算和 I/O 足以满足工作负荷要求,请考虑使用“基本”定价层。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 cannot later be scaled to General Purpose or Memory Optimized.

  1. 选择“查看 + 创建” 以预配服务器。Select Review + create to provision the server. 预配可能需要长达 20 分钟的时间。Provisioning can take up to 20 minutes.

  2. 在工具栏上选择“通知”(钟形图标)以监视部署过程。Select Notifications on the toolbar (the bell icon) to monitor the deployment process.

默认情况下,将在服务器下创建以下数据库:information_schemamysqlperformance_schemasysBy default, the following databases are created under your server: information_schema, mysql, performance_schema, and sys.

配置服务器级防火墙规则Configure a server-level firewall rule

默认情况下,创建的服务器使用防火墙进行保护,并且无法公开。By default the server created is protected with a firewall and is not accessible publicly. 若要授予对 IP 的访问权限,请转到 Azure 门户中的服务器资源,然后从左侧菜单中为服务器资源选择“连接安全性”。To give access to your IP, go to your server resource in the Azure portal and select Connection security from left-side menu for your server resource. 不知道如何找到资源时,请参阅如何打开资源Don't know how to find your resource, see How to open a resource.

连接安全性 - 防火墙规则Connection security - Firewall rules

现在选择“添加当前客户端 IP 地址”,然后选择“保存” 。Now select Add current client IP address and then select Save. 你可以添加其他 IP 或提供一个 IP 范围,从该范围中的 IP 连接到服务器。You can add additional IPs or provide an IP range to connect to your server from those IPs. 有关详细信息,请参阅如何在 Azure Database for MySQL 服务器上管理防火墙规则For more information, see How to manage firewall rules on Azure Database for MySQL server

备注

检查网络是否允许通过端口 3306 送出出站流量,该端口由 Azure Database for MySQL 使用,旨在避免连接问题。Check if your network allows outbound traffic over port 3306 that is used by Azure Database for MySQL to avoid connectivity issues.

使用 mysql 命令行客户端连接到 Azure Database for MySQL 服务器Connect to Azure Database for MySQL server using mysql command-line client

可以选择 mysql.exeMySQL Workbench,以从本地环境连接到服务器。You can choose either mysql.exe or MySQL Workbench to connect to the server from your local environment.

  1. 将值替换为实际的服务器名称和管理员用户登录名。Replace values with your actual server name and admin user login name. Azure Database for MySQL 的管理员用户名需要 @,如下所示The admin username requires '@ as shown below for Azure Database for MySQL
mysql --host=mydemoserver.mysql.database.chinacloudapi.cn --user=myadmin@mydemoserver -p 
  1. 创建数据库“guest”Create a database guest
mysql> CREATE DATABASE guest;
Query OK, 1 row affected (0.27 sec)
  1. 更改为数据库“guest”Change to database guest
mysql> USE guest;
Database changed 
  1. 键入 quit,然后选择 Enter 键退出 mysql。Type quit, and then select the Enter key to quit mysql.

清理资源Clean up resources

现在已成功在资源组中创建了 Azure Database for MySQL 服务器。You have successfully created an Azure Database for MySQL server in a resource group. 如果将来不再需要这些资源,可以通过删除资源组或只删除 MySQL 服务器来删除它们。If you don't expect to need these resources in the future, you can delete them by deleting the resource group or just delete the MySQL server. 若要删除资源组,请执行以下步骤:To delete the resource group, follow these steps:

  1. 在 Azure 门户中,搜索并选择“资源组”。In the Azure portal, search for and select Resource groups.
  2. 在资源组列表中,选择你的资源组的名称。In the resource group list, choose the name of your resource group.
  3. 在资源组的概述页面中,选择“删除资源组”。In the Overview page of your resource group, select Delete resource group.
  4. 在确认对话框中,键入资源组的名称,然后选择“删除”。In the confirmation dialog box, type the name of your resource group, and then select Delete.

若要删除服务器,可以单击服务器的“概述”页面上的“删除”按钮,如下所示 :To delete the server, you can click on Delete button on Overview page of your server as shown below:

删除资源Delete your resources

后续步骤Next steps