如何使用 Azure 门户在适用于 MySQL 的 Azure 数据库中配置服务器参数How to configure server parameters in Azure Database for MySQL by using the Azure portal

Note

将要查看的是 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.

用于 MySQL 的 Azure 数据库支持配置某些服务器参数。Azure Database for MySQL supports configuration of some server parameters. 本文介绍如何使用 Azure 门户配置这些参数。This article describes how to configure these parameters by using the Azure portal. 并非所有服务器参数都可调整。Not all server parameters can be adjusted.

  1. 登录到 Azure 门户,然后定位到适用于 MySQL 服务器的 Azure 数据库。Sign in to the Azure portal, then locate your Azure Database for MySQL server.
  2. 在“设置” 部分下,单击“服务器参数” ,打开 Azure Database for MySQL 服务器的“服务器参数”页。Under the SETTINGS section, click Server parameters to open the server parameters page for the Azure Database for MySQL server. Azure 门户中的服务器参数页Azure portal server parameters page
  3. 定位需要调整的任何设置。Locate any settings you need to adjust. 查看“说明”列 ,了解用途和允许的值。Review the Description column to understand the purpose and allowed values. 枚举下拉按钮Enumerate drop down
  4. 单击“保存” ,保存更改。Click Save to save your changes. 保存或放弃更改Save or Discard changes
  5. 保存参数的新值后,随时可以通过选择“全部重置为默认设置”,将所有设置还原为默认值。 If you have saved new values for the parameters, you can always revert everything back to the default values by selecting Reset all to default. 全部重置为默认设置Reset all to default

可配置的服务器参数列表List of configurable server parameters

受支持服务器参数的列表还在不断增加。The list of supported server parameters is constantly growing. 在 Azure 门户中使用服务器参数选项卡,以根据应用程序要求获取定义并配置服务器参数。Use the server parameters tab in Azure portal to get the definition and configure server parameters based on your application requirements.

不可配置的服务器参数Non-configurable server parameters

InnoDB 缓冲池大小不可配置,并且与定价层关联。The InnoDB Buffer Pool size is not configurable and tied to your pricing tier.

定价层Pricing Tier vCore(s)vCore(s) InnoDB 缓冲池 (MB)InnoDB Buffer Pool size in MB
基本Basic 11 832832
基本Basic 22 25602560
常规用途General Purpose 22 35843584
常规用途General Purpose 44 76807680
常规用途General Purpose 88 1536015360
常规用途General Purpose 1616 3123231232
常规用途General Purpose 3232 6297662976
常规用途General Purpose 6464 125952125952
内存优化Memory Optimized 22 71687168
内存优化Memory Optimized 44 1536015360
内存优化Memory Optimized 88 3072030720
内存优化Memory Optimized 1616 6246462464
内存优化Memory Optimized 3232 125952125952

以下附加服务器参数不可在系统中配置:These additional server parameters are not configurable in the system:

参数Parameter 固定值Fixed value
基本层中的 innodb_file_per_tableinnodb_file_per_table in Basic tier OFFOFF
innodb_flush_log_at_trx_commitinnodb_flush_log_at_trx_commit 11
sync_binlogsync_binlog 11
innodb_log_file_sizeinnodb_log_file_size 512MB512MB

在版本 5.75.6 中,上表中未列出的其他服务器参数将设置为其 MySQL 现成默认值。Other server parameters that are not listed here are set to their MySQL out-of-box default values for versions 5.7 and 5.6.

使用时区参数Working with the time zone parameter

填充时区表Populating the time zone tables

可以通过从 MySQL 命令行或 MySQL Workbench 等工具调用 mysql.az_load_timezone 存储过程,填充服务器上的时区表。The time zone tables on your server can be populated by calling the mysql.az_load_timezone stored procedure from a tool like the MySQL command line or MySQL Workbench.

Note

如果正在运行 MySQL Workbench 中的 mysql.az_load_timezone 命令,可能需要先使用 SET SQL_SAFE_UPDATES=0; 关闭安全更新模式。If you are running the mysql.az_load_timezone command from MySQL Workbench, you may need to turn off safe update mode first using SET SQL_SAFE_UPDATES=0;.

CALL mysql.az_load_timezone();

Important

应重启服务器,确保正确填充时区表。You should restart the server to ensure the time zone tables are properly populated. 要重启服务器,请使用 Azure 门户CLITo restart the server, use the Azure portal or CLI.

要查看可用的时区值,请运行以下命令:To view available time zone values, run the following command:

SELECT name FROM mysql.time_zone_name;

设置全局级时区Setting the global level time zone

可以从 Azure 门户中的“服务器参数” 页设置全局级时区。The global level time zone can be set from the Server parameters page in the Azure portal. 下面将全局时区值设置为“美国/太平洋”。The below sets the global time zone to the value "US/Pacific".

设置时区参数

设置会话级时区Setting the session level time zone

可以通过从 MySQL 命令行或 MySQL Workbench 等工具运行 SET time_zone 命令来设置会话级时区。The session level time zone can be set by running the SET time_zone command from a tool like the MySQL command line or MySQL Workbench. 以下示例将时区设置为“美国/太平洋” 时区。The example below sets the time zone to the US/Pacific time zone.

SET time_zone = 'US/Pacific';

若要了解日期和时间函数,请参阅 MySQL 文档。Refer to the MySQL documentation for Date and Time Functions.

后续步骤Next steps