使用 Azure 门户在 Azure Database for MariaDB 中配置服务器参数Configure server parameters in Azure Database for MariaDB using the Azure portal

Azure Database for MariaDB 支持配置某些服务器参数。Azure Database for MariaDB 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.

备注

可在服务器级别全局更新服务器参数,方式是使用 Azure CLIPowerShellAzure 门户Server parameters can be updated globally at the server-level, use the Azure CLI, PowerShell, or Azure portal.

配置服务器参数Configure server parameters

  1. 登录到 Azure 门户,然后定位到 Azure Database for MariaDB 服务器。Sign in to the Azure portal, then locate your Azure Database for MariaDB server.
  2. 在“设置”部分下,单击“服务器参数”,打开 Azure Database for MariaDB 服务器的“服务器参数”页。Under the SETTINGS section, click Server parameters to open the server parameters page for the Azure Database for MariaDB 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

设置参数未列出Setting parameters not listed

如果 Azure 门户中未列出你要更新的服务器参数,则可以选择性地使用 init_connect 在连接级别设置参数。If the server parameter you want to update is not listed in the Azure portal, you can optionally set the parameter at the connection level using init_connect. 此项可为每个连接到服务器的客户端设置服务器参数。This sets the server parameters for each client connecting to the server.

  1. 在“设置”部分下,单击“服务器参数”,打开 Azure Database for MariaDB 服务器的“服务器参数”页。Under the SETTINGS section, click Server parameters to open the server parameters page for the Azure Database for MariaDB server.

  2. 搜索 init_connectSearch for init_connect

  3. 在 value 列的 value 中添加服务器参数,格式为 SET parameter_name=YOUR_DESIRED_VALUEAdd the server parameters in the format: SET parameter_name=YOUR_DESIRED_VALUE in value the value column.

    例如,可以通过将 init_connect 设置为 SET character_set_client=utf8;SET character_set_database=utf8mb4;SET character_set_connection=latin1;SET character_set_results=latin1; 来更改服务器的字符集For example, you can change the character set of your server by setting of init_connect to SET character_set_client=utf8;SET character_set_database=utf8mb4;SET character_set_connection=latin1;SET character_set_results=latin1;

  4. 以保存更改。Click Save to save your changes.

使用时区参数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.

备注

如果正在运行 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();

重要

应重启服务器,确保正确填充时区表。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 "Asia/Shanghai".

设置时区参数

设置会话级时区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 Asia/Shanghai time zone.

SET time_zone = 'Asia/Shanghai';

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

后续步骤Next steps