文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 85%

7.1.8 服务器系统变量7.1.8 Server System Variables

MySQL 服务器维护许多影响其操作的系统变量。大多数系统变量可以在服务器启动时通过命令行选项或选项文件设置。大多数变量可以在运行时动态更改,使用 SET 语句,这样可以在不停止和重启服务器的情况下修改服务器的操作。一些变量是只读的,其值由系统环境、MySQL 在系统上的安装方式或可能由编译 MySQL 时使用的选项决定。大多数系统变量都有默认值,但也有例外,包括只读变量。您还可以在表达式中使用系统变量的值。The MySQL server maintains many system variables that affect its operation. Most system variables can be set at server startup using options on the command line or in an option file. Most of them can be changed dynamically at runtime using the SET statement, which enables you to modify operation of the server without having to stop and restart it. Some variables are read-only, and their values are determined by the system environment, by how MySQL is installed on the system, or possibly by the options used to compile MySQL. Most system variables have a default value, but there are exceptions, including read-only variables. You can also use system variable values in expressions.

通常,设置全局系统变量的运行时值需要SYSTEM_VARIABLES_ADMIN权限(或已弃用的SUPER权限)。通常,设置会话系统运行时变量的值不需要特殊权限,任何用户都可以执行,但也存在例外。更多信息,请参见第 7.1.9.1 节,“系统变量权限”Setting a global system variable runtime value normally requires the SYSTEM_VARIABLES_ADMIN privilege (or the deprecated SUPER privilege). Setting a session system runtime variable value normally requires no special privileges and can be done by any user, although there are exceptions. For more information, see Section 7.1.9.1, “System Variable Privileges”

有几种方法可以查看系统变量的名称和值:There are several ways to see the names and values of system variables:

  • 要查看服务器根据其编译默认值和读取的任何选项文件使用的值,请使用此命令:To see the values that a server uses based on its compiled-in defaults and any option files that it reads, use this command:

    mysqld --verbose --help
    
  • 要查看服务器仅根据其编译默认值使用的值,忽略任何选项文件中的设置,请使用此命令:To see the values that a server uses based only on its compiled-in defaults, ignoring the settings in any option files, use this command:

    mysqld --no-defaults --verbose --help
    
  • 要查看正在运行的服务器使用的当前值,请使用SHOW VARIABLES语句或性能模式系统变量表。请参阅第 29.12.14 节,“Performance Schema 系统变量表”。To see the current values used by a running server, use the SHOW VARIABLES statement or the Performance Schema system variable tables. See Section 29.12.14, “Performance Schema System Variable Tables”.

本节提供了每个系统变量的描述。有关系统变量汇总表,请参阅第 7.1.5 节,“服务器系统变量参考”。有关系统变量操作的更多信息,请参阅第 7.1.9 节,“使用系统变量”。This section provides a description of each system variable. For a system variable summary table, see Section 7.1.5, “Server System Variable Reference”. For more information about manipulation of system variables, see Section 7.1.9, “Using System Variables”.

有关其他系统变量的信息,请参阅以下部分:For additional system variable information, see these sections:

Note

以下一些变量描述涉及 “enabling” 或 “disabling” 变量。这些变量可以通过 SET 语句来启用,方法是将其设置为 ON 或 1,或者通过设置为 OFF 或 0 来禁用。布尔变量可在启动时设置为 ON、TRUEOFF以及 FALSE(不区分大小写),以及 1 和 0。参见 第 6.2.2.4 节,“Program Option Modifiers”。Some of the following variable descriptions refer to “enabling” or “disabling” a variable. These variables can be enabled with the SET statement by setting them to ON or 1, or disabled by setting them to OFF or 0. Boolean variables can be set at startup to the values ON, TRUE, OFF, and FALSE (not case-sensitive), as well as 1 and 0. See Section 6.2.2.4, “Program Option Modifiers”.

一些系统变量控制缓冲区或缓存的大小。对于给定的缓冲区,服务器可能需要分配内部数据结构。这些结构通常从分配给缓冲区的总内存中分配,而所需的空间量可能依赖于平台。这意味着当你为控制缓冲区大小的系统变量分配一个值时,实际可用的空间可能与分配的值不同。在某些情况下,可用空间可能少于分配的值。服务器也可能会将值调高。例如,如果你为一个最小值为 1024 的变量分配 0,服务器会将该值设置为 1024。Some system variables control the size of buffers or caches. For a given buffer, the server might need to allocate internal data structures. These structures typically are allocated from the total memory allocated to the buffer, and the amount of space required might be platform dependent. This means that when you assign a value to a system variable that controls a buffer size, the amount of space actually available might differ from the value assigned. In some cases, the amount might be less than the value assigned. It is also possible that the server adjusts a value upward. For example, if you assign a value of 0 to a variable for which the minimal value is 1024, the server sets the value to 1024.

缓冲区大小、长度和堆栈大小的值以字节为单位,除非另有说明。Values for buffer sizes, lengths, and stack sizes are given in bytes unless otherwise specified.

Note

某些系统变量的描述包括块大小,在这种情况下,如果值不是所述块大小的整数倍,则在服务器存储之前会向下舍入到块大小的下一个较低倍数,即FLOOR(value) * block_size。Some system variable descriptions include a block size, in which case a value that is not an integer multiple of the stated block size is rounded down to the next lower multiple of the block size before being stored by the server, that is to FLOOR(value) * block_size.

示例:假设某个变量的块大小为 4096,并且你将该变量的值设置为 100000(假设该变量的最大值大于此数)。由于 100000 / 4096 = 24.4140625,服务器会在存储之前自动将值降低到 98304(24 * 4096)。Example: Suppose that the block size for a given variable is given as 4096, and you set the value of the variable to 100000 (we assume that the variable's maximum value is greater than this number). Since 100000 / 4096 = 24.4140625, the server automatically lowers the value to 98304 (24 * 4096) before storing it.

在某些情况下,变量的声明最大值是 MySQL 解析器允许的最大值,但不是块大小的精确倍数。在这种情况下,有效的最大值是下一个较低的块大小倍数。In some cases, the stated maximum for a variable is the maximum allowed by the MySQL parser, but is not an exact multiple of the block size. In such cases, the effective maximum is the next lower multiple of the block size.

示例:一个系统变量的最大值显示为 4294967295 (232-1),其块大小为 1024。4294967295 / 1024 = 4194303.9990234375,所以如果将该变量设置为其指定的最大值,实际存储的值为 4194303 * 1024 = 4294966272。Example: A system variable's maxmum value is shown as 4294967295 (232-1), and its block size is 1024. 4294967295 / 1024 = 4194303.9990234375, so if you set this variable to its stated maximum, the value actually stored is 4194303 * 1024 = 4294966272.

一些系统变量需要文件名值。除非另有说明,如果值是相对路径名,默认的文件位置是数据目录。要明确指定位置,请使用绝对路径名。假设数据目录为 /var/mysql/data。如果文件值变量给出的是相对路径名,则其位置在 /var/mysql/data 下。如果值是绝对路径名,则其位置按路径名指定。Some system variables take file name values. Unless otherwise specified, the default file location is the data directory if the value is a relative path name. To specify the location explicitly, use an absolute path name. Suppose that the data directory is /var/mysql/data. If a file-valued variable is given as a relative path name, it is located under /var/mysql/data. If the value is an absolute path name, its location is as given by the path name.

  • activate_all_roles_on_login

    命令行格式Command-Line Format --activate-all-roles-on-login[={OFF|ON}]
    系统变量System Variable activate_all_roles_on_login
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    是否在用户登录服务器时启用所有授予角色的自动激活:Whether to enable automatic activation of all granted roles when users log in to the server:

    授予的角色包括显式授予用户的角色以及在mandatory_roles系统变量值中列出的角色。Granted roles include those granted explicitly to the user and those named in the mandatory_roles system variable value.

    activate_all_roles_on_login仅在登录时以及在以定义者上下文执行的存储程序和视图开始执行时生效。要在会话中更改活动角色,请使用SET ROLE。要更改存储程序的活动角色,程序主体应执行SET ROLE。activate_all_roles_on_login applies only at login time, and at the beginning of execution for stored programs and views that execute in definer context. To change the active roles within a session, use SET ROLE. To change the active roles for a stored program, the program body should execute SET ROLE.

  • admin_address

    命令行格式Command-Line Format --admin-address=addr--admin-address=addr
    系统变量System Variable admin_address
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    用于在管理网络接口上监听 TCP/IP 连接的 IP 地址(参见第 7.1.12.1 节,“连接接口”)。没有默认的admin_address值。如果在启动时未指定此变量,服务器将不维护管理接口。服务器还具有一个bind_address系统变量,用于配置常规(非管理)客户端 TCP/IP 连接。参见第 7.1.12.1 节,“连接接口”。The IP address on which to listen for TCP/IP connections on the administrative network interface (see Section 7.1.12.1, “Connection Interfaces”). There is no default admin_address value. If this variable is not specified at startup, the server maintains no administrative interface. The server also has a bind_address system variable for configuring regular (nonadministrative) client TCP/IP connections. See Section 7.1.12.1, “Connection Interfaces”.

    如果指定了 admin_address,其值必须满足以下要求:If admin_address is specified, its value must satisfy these requirements:

    • 该值必须是单个 IPv4 地址、IPv6 地址或主机名。The value must be a single IPv4 address, IPv6 address, or host name.

    • 该值不能指定通配符地址格式(*、0.0.0.0 或 ::)。The value cannot specify a wildcard address format (*, 0.0.0.0, or ::).

    • 该值可能包含网络命名空间说明符。The value may include a network namespace specifier.

    可以将 IP 地址指定为 IPv4 或 IPv6 地址。如果该值是主机名,服务器会将其解析为 IP 地址并绑定到该地址。如果一个主机名解析为多个 IP 地址,服务器将使用第一个 IPv4 地址(如果有),否则使用第一个 IPv6 地址。An IP address can be specified as an IPv4 or IPv6 address. If the value is a host name, the server resolves the name to an IP address and binds to that address. If a host name resolves to multiple IP addresses, the server uses the first IPv4 address if there are any, or the first IPv6 address otherwise.

    服务器对不同类型的地址的处理如下:The server treats different types of addresses as follows:

    • 如果地址是 IPv4 映射地址,服务器接受该地址的 TCP/IP 连接,无论是 IPv4 还是 IPv6 格式。例如,如果服务器绑定到 ::ffff:127.0.0.1,客户端可以使用 --host=127.0.0.1 或 --host=::ffff:127.0.0.1 连接。If the address is an IPv4-mapped address, the server accepts TCP/IP connections for that address, in either IPv4 or IPv6 format. For example, if the server is bound to ::ffff:127.0.0.1, clients can connect using --host=127.0.0.1 or --host=::ffff:127.0.0.1.

    • 如果地址是“常规” IPv4 或 IPv6 地址(例如 127.0.0.1 或 ::1),服务器只接受针对该 IPv4 或 IPv6 地址的 TCP/IP 连接。If the address is a “regular” IPv4 or IPv6 address (such as 127.0.0.1 or ::1), the server accepts TCP/IP connections only for that IPv4 or IPv6 address.

    这些规则适用于为地址指定网络命名空间:These rules apply to specifying a network namespace for an address:

    • 可以为 IP 地址或主机名指定网络命名空间。A network namespace can be specified for an IP address or a host name.

    • 不能为通配符 IP 地址指定网络命名空间。A network namespace cannot be specified for a wildcard IP address.

    • 对于给定的地址,网络命名空间是可选的。如果提供,必须作为紧跟地址的一个/ns后缀来指定。For a given address, the network namespace is optional. If given, it must be specified as a /ns suffix immediately following the address.

    • 没有/ns后缀的地址使用主机系统的全局命名空间。因此,全局命名空间是默认值。An address with no /ns suffix uses the host system global namespace. The global namespace is therefore the default.

    • 带有/ns后缀的地址使用名为ns的命名空间。An address with a /ns suffix uses the namespace named ns.

    • 主机系统必须支持网络命名空间,并且每个命名的命名空间必须事先设置好。命名不存在的命名空间会产生错误。The host system must support network namespaces and each named namespace must previously have been set up. Naming a nonexistent namespace produces an error.

    有关网络命名空间的更多信息,请参见第 7.1.14 节,“网络命名空间支持”。For additional information about network namespaces, see Section 7.1.14, “Network Namespace Support”.

    如果绑定到地址失败,服务器会产生错误并且不会启动。If binding to the address fails, the server produces an error and does not start.

    admin_address 系统变量类似于 bind_address 系统变量,它将服务器绑定到用于普通客户端连接的地址,但有以下区别:The admin_address system variable is similar to the bind_address system variable that binds the server to an address for ordinary client connections, but with these differences:

  • admin_port

    命令行格式Command-Line Format --admin-port=port_num--admin-port=port_num
    系统变量System Variable admin_port
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 33062
    最小值Minimum Value 0
    最大值Maximum Value 65535

    用于管理网络接口连接的 TCP/IP 端口号(参见 第 7.1.12.1 节,“连接接口”)。将此变量设置为 0 会使用默认值。The TCP/IP port number to use for connections on the administrative network interface (see Section 7.1.12.1, “Connection Interfaces”). Setting this variable to 0 causes the default value to be used.

    如果未指定 admin_address,则设置 admin_port 无效,因为在这种情况下,服务器不会维护任何管理网络接口。Setting admin_port has no effect if admin_address is not specified because in that case the server maintains no administrative network interface.

  • admin_ssl_ca

    命令行格式Command-Line Format --admin-ssl-ca=file_name--admin-ssl-ca=file_name
    系统变量System Variable admin_ssl_ca
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    admin_ssl_ca 系统变量类似于 ssl_ca,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参阅 管理接口加密连接支持。The admin_ssl_ca system variable is like ssl_ca, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

  • admin_ssl_capath

    命令行格式Command-Line Format --admin-ssl-capath=dir_name--admin-ssl-capath=dir_name
    系统变量System Variable admin_ssl_capath
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value NULL

    admin_ssl_capath 系统变量类似于 ssl_capath,只是它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参阅 管理接口加密连接支持。The admin_ssl_capath system variable is like ssl_capath, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

  • admin_ssl_cert

    命令行格式Command-Line Format --admin-ssl-cert=file_name--admin-ssl-cert=file_name
    系统变量System Variable admin_ssl_cert
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    admin_ssl_cert 系统变量类似于 ssl_cert,区别在于它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参阅 管理接口加密连接支持。The admin_ssl_cert system variable is like ssl_cert, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

  • admin_ssl_cipher

    命令行格式Command-Line Format --admin-ssl-cipher=name
    系统变量System Variable admin_ssl_cipher
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value NULL

    admin_ssl_cipher 系统变量类似于 ssl_cipher,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参阅 管理接口加密连接支持。The admin_ssl_cipher system variable is like ssl_cipher, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

    此变量指定的列表可能包括以下任何值:The list specified by this variable may include any of the following values:

    • ECDHE-ECDSA-AES128-GCM-SHA256

    • ECDHE-ECDSA-AES256-GCM-SHA384

    • ECDHE-RSA-AES128-GCM-SHA256

    • ECDHE-RSA-AES256-GCM-SHA384

    • ECDHE-ECDSA-CHACHA20-POLY1305

    • ECDHE-RSA-CHACHA20-POLY1305

    • ECDHE-ECDSA-AES256-CCM

    • ECDHE-ECDSA-AES128-CCM

    • DHE-RSA-AES128-GCM-SHA256

    • DHE-RSA-AES256-GCM-SHA384

    • DHE-RSA-AES256-CCM

    • DHE-RSA-AES128-CCM

    • DHE-RSA-CHACHA20-POLY1305

    在设置此变量时,如果尝试在密码列表中包含此处未显示的任何值,将引发错误(ER_BLOCKED_CIPHER)。Trying to include any values in the cipher list that are not shown here when setting this variable raises an error (ER_BLOCKED_CIPHER).

  • admin_ssl_crl

    命令行格式Command-Line Format --admin-ssl-crl=file_name--admin-ssl-crl=file_name
    系统变量System Variable admin_ssl_crl
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    admin_ssl_crl 系统变量类似于 ssl_crl,只是它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参见 管理接口加密连接支持。The admin_ssl_crl system variable is like ssl_crl, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

  • admin_ssl_crlpath

    命令行格式Command-Line Format --admin-ssl-crlpath=dir_name
    系统变量System Variable admin_ssl_crlpath
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value NULL

    admin_ssl_crlpath 系统变量类似于 ssl_crlpath,只是它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参阅 行政接口对加密连接的支持。The admin_ssl_crlpath system variable is like ssl_crlpath, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

  • admin_ssl_key

    命令行格式Command-Line Format --admin-ssl-key=file_name--admin-ssl-key=file_name
    系统变量System Variable admin_ssl_key
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    admin_ssl_key 系统变量类似于 ssl_key,不同之处在于它适用于管理连接接口而非主连接接口。有关配置管理接口加密支持的信息,请参见 管理接口加密连接支持。The admin_ssl_key system variable is like ssl_key, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

  • admin_tls_ciphersuites

    命令行格式Command-Line Format --admin-tls-ciphersuites=ciphersuite_list
    系统变量System Variable admin_tls_ciphersuites
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value NULL

    admin_tls_ciphersuites 系统变量类似于 tls_ciphersuites,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参阅 管理接口加密连接支持。The admin_tls_ciphersuites system variable is like tls_ciphersuites, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

    该值是一个包含零个或多个冒号分隔的密码套件名称的列表,这些名称来自此处列出的选项:The value is a list of zero or more colon-separated ciphersuite names from among those listed here:

    • TLS_AES_128_GCM_SHA256

    • TLS_AES_256_GCM_SHA384

    • TLS_CHACHA20_POLY1305_SHA256

    • TLS_AES_128_CCM_SHA256

    在设置此变量时,如果尝试在密码列表中包含此处未显示的任何值,将引发错误(ER_BLOCKED_CIPHER)。Trying to include any values in the cipher list that are not shown here when setting this variable raises an error (ER_BLOCKED_CIPHER).

  • admin_tls_version

    命令行格式Command-Line Format --admin-tls-version=protocol_list--admin-tls-version=protocol_list
    系统变量System Variable admin_tls_version
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value TLSv1.2,TLSv1.3

    admin_tls_version 系统变量类似于 tls_version,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参见 管理接口加密连接支持。The admin_tls_version system variable is like tls_version, except that it applies to the administrative connection interface rather than the main connection interface. For information about configuring encryption support for the administrative interface, see Administrative Interface Support for Encrypted Connections.

    Important
    • MySQL 8.4 不支持 TLSv1 和 TLSv1.1 连接协议。有关详细信息,请参阅 删除对 TLSv1 和 TLSv1.1 协议的支持。MySQL 8.4 does not support the TLSv1 and TLSv1.1 connection protocols. See Removal of Support for the TLSv1 and TLSv1.1 Protocols for more information.

    • MySQL 8.4 支持 TLSv1.3 协议,前提是 MySQL 服务器是使用 OpenSSL 1.1.1 或更新版本编译的。服务器在启动时会检查 OpenSSL 的版本,如果版本低于 1.1.1,TLSv1.3 将从系统变量的默认值中移除。在这种情况下,默认值是 TLSv1.2。MuySQL 8.4 supports the TLSv1.3 protocol, provided that the MySQL server was compiled using OpenSSL 1.1.1 or newer. The server checks the version of OpenSSL at startup, and if it is older than 1.1.1, TLSv1.3 is removed from the default value for the system variable. In that case, the default is TLSv1.2.

  • authentication_policy

    命令行格式Command-Line Format --authentication-policy=value
    系统变量System Variable authentication_policy
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value *,,

    此变量用于管理多因素认证(MFA)功能。对于用于管理 MySQL 账户定义的 CREATE USER 和 ALTER USER 语句,它决定了可以指定哪些认证因素,其中 “factor” 对应于与账户关联的认证方法或插件。authentication_policy 确定多因素认证的以下方面:This variable is used to administer multifactor authentication (MFA) capabilities. For CREATE USER and ALTER USER statements used to manage MySQL account definitions, it determines what authentication factor or factors may be specified, where “factor” corresponds to an authentication method or plugin associated with an account. authentication_policy determines the following aspects of multifactor authentication:

    • 认证因素的数量。The number of authentication factors.

    • 每个因素允许的插件(或方法)。The plugins (or methods) permitted for each factor.

    • 对于未显式指定插件的认证规范,默认的认证插件。The default authentication plugin for authentication specifications that do not name a plugin explicitly.

    因为authentication_policy仅在创建或修改账户时适用,所以其值的更改不会影响现有用户账户。Because authentication_policy applies only when accounts are created or altered, changes to its value have no effect on existing user accounts.

    Note

    虽然 authentication_policy 系统变量对 CREATE USER 和 ALTER USER 语句中的与认证相关的子句施加了某些限制,但拥有 AUTHENTICATION_POLICY_ADMIN 权限的用户不受这些限制约束。(对于原本不允许的语句,会出现警告。)Although the authentication_policy system variable places certain constraints on the authentication-related clauses of CREATE USER and ALTER USER statements, a user who has the AUTHENTICATION_POLICY_ADMIN privilege is not subject to these constraints. (A warning does occur for statements that otherwise would not be permitted.)

    authentication_policy 的值是由 1、2 或 3 个逗号分隔的元素组成的列表,每个元素对应一个身份验证因素,并且每个元素的形式为此处列出的之一,其含义如下:The value of authentication_policy is a list of 1, 2, or 3 comma-separated elements, each corresponding to an authentication factor and each being of one of the forms listed here, with their meanings:

    • 空empty

      身份验证因素是可选的;可以使用任何身份验证插件。The authentication factor is optional; any authentication plugin may be used.

    • *

      身份验证因素是必需的;可以使用任何身份验证插件。The authentication factor is required; any authentication plugin may be used.

    • plugin_name

      需要身份验证因素;此因素必须是plugin_name。The authentication factor is required; this factor must be plugin_name.

    • *:plugin_name

      需要身份验证因素;plugin_name是默认值,但也可以使用其他身份验证插件。The authentication factor is required; plugin_name is the default, but another authentication plugin may be used.

    在每种情况下,元素可能被空白字符包围。整个列表必须用单引号括起来。In each case, an element may be surrounded by whitespace characters. The entire list must be enclosed in single quotes.

    authentication_policy 必须至少包含一个非空因子,且任何空因子必须出现在列表的末尾,位于所有非空因子之后。这意味着 ',,' 是不允许的,因为这表示所有因子都是可选的。每个账户必须至少有一个认证因子。authentication_policy must contain at least one nonempty factor, and any empty factors must come at the end of the list, following any nonempty factors. This means that ',,' is not permitted because this signifies that all factors are optional. Every account must have at least one authentication factor.

    authentication_policy 的默认值是 '*,,'。这意味着在账户定义中,因子 1 是必需的,可以使用任何认证插件(默认为 caching_sha2_password),而因子 2 和 3 是可选的,每个都可以使用任何认证插件。The default value of authentication_policy is '*,,'. This means that factor 1 is required in account definitions and can use any authentication plugin (with caching_sha2_password being the default), and that factors 2 and 3 are optional and each can use any authentication plugin.

    如果 authentication_policy 没有为第一因素指定默认插件,则该因素的默认插件是 caching_sha2_password,虽然也可以使用其他插件。If authentication_policy does not specify a default plugin for the first factor, the default plugin for this factor is caching_sha2_password, although another plugin may be used.

    下表显示了一些 authentication_policy 的可能值以及每个值在创建或更改账户时所建立的策略。The following table shows some possible values for authentication_policy and the policy that each establishes for creating or altering accounts.

    表 7.4 验证策略(authentication_policy)示例值Table 7.4 Example authentication_policy Values

    身份验证策略authentication_policy 策略Policy
    '*' 仅一个因素,使用 caching_sha2_password,尽管可以使用其他插件。One factor only, which uses caching_sha2_password, although another plugin may be used.
    '*,*' 仅两个因素;第一个因素默认使用 caching_sha2_password,尽管可以使用其他插件;第二个因素可以使用任何插件。Two factors only; the first factor uses caching_sha2_password by default, although another plugin may be used; the second may use any plugin.
    '*,*,*' 仅三个因素,其中第一个因素默认使用 caching_sha2_password,尽管可以使用其他插件;第二和第三个因素可以使用任何插件。Three factors only, where the first factor uses caching_sha2_password by default, although another plugin may be used; the second and third factors may use any plugins.
    '*,' 一或两个因素,其中第一个因素默认使用 caching_sha2_password,尽管可以使用其他插件;第二个因素是可选的,可以使用任何插件。One or two factors, where the first factor uses caching_sha2_password by default, although another plugin may be used; the second factor is optional and may use any plugin.
    '*,,' 一、二或三因素,其中第一个因素默认使用 caching_sha2_password,尽管可以使用其他插件;第二个因素和第三因素是可选的,可以使用任何插件。One, two, or three factors, where the first factor uses caching_sha2_password by default, although another plugin may be used; the second factor and third factors are optional and may use any plugins.
    '*,*,' 两到三个因素,第一个因素默认使用caching_sha2_password,尽管也可以使用其他插件;第二个因素是必需的,第三个因素是可选的;第二和第三因素可以使用任何插件。Two or three factors, where the first factor uses caching_sha2_password by default, although another plugin may be used; the second factor is required and the third factor is optional; the second and third factors may use any plugins.
    '*,auth_plugin' 两个因素,第一个因素默认使用caching_sha2_password,尽管也可以使用其他插件;第二个因素必须是指定插件。Two factors, where the first factor uses caching_sha2_password by default, although another plugin may be used; the second factor must be the named plugin.
    'auth_plugin,*,' 两个或三个因素,其中第一个因素必须是指定的插件;第二个因素是必需的,但可以使用任何插件;第三个因素是可选的,可以使用任何插件。Two or three factors, where the first factor must be the named plugin; the second factor is required but may use any plugin; the third factor is optional and may use any plugin.
    '*,*:auth_plugin' 两个因子,第一个因子默认使用caching_sha2_password,但也可以使用其他插件;第二个因子是必需的,使用指定的插件,但也可以使用其他插件。Two factors, where the first factor uses caching_sha2_password by default, although another plugin may be used; the second factor is required and uses the named plugin, but another plugin may be used.
    'auth_plugin,' 一到两个因素,其中第一个因素必须是指定的插件;第二个因素是可选的,可以使用任何插件。One or two factors, where the first factor must be the named plugin; the second factor is optional and may use any plugin.
    '*:auth_plugin,*,' 两到三个因素,其中第一个因素必须是指定的插件;第二个因素是必需的,可以使用任何插件,第三个因素是可选的,也可以使用任何插件。Two or three factors, where the first factor must be the named plugin; the second factor is required and may use any plugin, and the third factor is optional and may use any plugin.
    'auth_plugin,auth_plugin,auth_plugin' 三个因素,且这三个因素都必须使用指定的插件。Three factors, where all three factors must use the named plugins.

  • authentication_windows_log_level

    命令行格式Command-Line Format --authentication-windows-log-level=#
    系统变量System Variable authentication_windows_log_level
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 2
    最小值Minimum Value 0
    最大值Maximum Value 4

    仅当启用了 authentication_windows Windows 身份验证插件并启用了调试代码时,此变量才可用。请参阅 第 8.4.1.6 节,“Windows 可插拔身份验证”。This variable is available only if the authentication_windows Windows authentication plugin is enabled and debugging code is enabled. See Section 8.4.1.6, “Windows Pluggable Authentication”.

    此变量设置 Windows 身份验证插件的日志记录级别。下表显示允许的值。This variable sets the logging level for the Windows authentication plugin. The following table shows the permitted values.

    价值Value 说明Description
    0 无日志记录No logging
    1 仅记录错误消息Log only error messages
    2 记录级别 1 消息和警告消息Log level 1 messages and warning messages
    3 记录级别 2 消息和信息提示Log level 2 messages and information notes
    4 记录级别 3 消息和调试消息Log level 3 messages and debug messages
  • authentication_windows_use_principal_name

    命令行格式Command-Line Format --authentication-windows-use-principal-name[={OFF|ON}]
    系统变量System Variable authentication_windows_use_principal_name
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    该变量仅在启用 authentication_windows Windows 身份验证插件时可用。参见 第 8.4.1.6 节,“Windows 插件式身份验证”。This variable is available only if the authentication_windows Windows authentication plugin is enabled. See Section 8.4.1.6, “Windows Pluggable Authentication”.

    使用 InitSecurityContext() 函数进行身份验证的客户端应提供一个标识其连接的服务的字符串 (targetName)。MySQL 使用服务器运行帐户的主体名称 (UPN)。UPN 的形式为 user_id@computer_name,无需在任何地方注册即可使用。该 UPN 会在身份验证握手开始时由服务器发送。A client that authenticates using the InitSecurityContext() function should provide a string identifying the service to which it connects (targetName). MySQL uses the principal name (UPN) of the account under which the server is running. The UPN has the form user_id@computer_name and need not be registered anywhere to be used. This UPN is sent by the server at the beginning of authentication handshake.

    此变量用于控制服务器是否在初始挑战中发送 UPN。默认情况下,该变量为启用状态。出于安全原因,可以将其禁用,以避免将服务器的帐户名称以明文形式发送给客户端。如果该变量被禁用,服务器在第一次挑战中总是发送一个 0x00 字节,客户端不会指定 targetName,因此会使用 NTLM 身份验证。This variable controls whether the server sends the UPN in the initial challenge. By default, the variable is enabled. For security reasons, it can be disabled to avoid sending the server's account name to a client as cleartext. If the variable is disabled, the server always sends a 0x00 byte in the first challenge, the client does not specify targetName, and as a result, NTLM authentication is used.

    如果服务器无法获取其 UPN(这主要发生在不支持 Kerberos 身份验证的环境中),服务器将不会发送 UPN,并使用 NTLM 身份验证。If the server fails to obtain its UPN (which happens primarily in environments that do not support Kerberos authentication), the UPN is not sent by the server and NTLM authentication is used.

  • autocommit autocommit

    命令行格式Command-Line Format --autocommit[={OFF|ON}]--autocommit[={OFF|ON}]
    系统变量System Variable autocommitautocommit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    自动提交模式。如果设置为 1,对表的所有更改会立即生效。如果设置为 0,您必须使用COMMIT 来接受事务,或者使用ROLLBACK 来取消事务。如果autocommit 为 0 并且您将其更改为 1,MySQL 会对任何未提交的事务执行自动COMMIT。另一种开始事务的方法是使用START TRANSACTION 或BEGIN 语句。参见第 15.3.1 节,“START TRANSACTION、COMMIT 和 ROLLBACK 语句”。The autocommit mode. If set to 1, all changes to a table take effect immediately. If set to 0, you must use COMMIT to accept a transaction or ROLLBACK to cancel it. If autocommit is 0 and you change it to 1, MySQL performs an automatic COMMIT of any open transaction. Another way to begin a transaction is to use a START TRANSACTION or BEGIN statement. See Section 15.3.1, “START TRANSACTION, COMMIT, and ROLLBACK Statements”.

    默认情况下,客户端连接的 autocommit 设置为 1。若要使客户端以默认 0 开始,请通过使用 --autocommit=0 选项启动服务器来设置全局 autocommit 值。要使用选项文件设置该变量,请包含以下行:By default, client connections begin with autocommit set to 1. To cause clients to begin with a default of 0, set the global autocommit value by starting the server with the --autocommit=0 option. To set the variable using an option file, include these lines:

    [mysqld]
    autocommit=0
    
  • automatic_sp_privileges

    命令行格式Command-Line Format --automatic-sp-privileges[={OFF|ON}]
    系统变量System Variable automatic_sp_privileges
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    当此变量的值为 1(默认值)时,如果用户尚不能执行、修改或删除该存储例程,服务器会自动授予存储例程的创建者 EXECUTE 和 ALTER ROUTINE 权限。(删除例程需要 ALTER ROUTINE 权限。)当例程被删除时,服务器还会自动从创建者处移除这些权限。如果 automatic_sp_privileges 为 0,服务器不会自动添加或移除这些权限。When this variable has a value of 1 (the default), the server automatically grants the EXECUTE and ALTER ROUTINE privileges to the creator of a stored routine, if the user cannot already execute and alter or drop the routine. (The ALTER ROUTINE privilege is required to drop the routine.) The server also automatically drops those privileges from the creator when the routine is dropped. If automatic_sp_privileges is 0, the server does not automatically add or drop these privileges.

    例程的创建者是用于执行 CREATE 语句的账户。这可能与例程定义中作为 DEFINER 指定的账户不同。The creator of a routine is the account used to execute the CREATE statement for it. This might not be the same as the account named as the DEFINER in the routine definition.

    如果你用 mysqld 并加上 --skip-new 启动,automatic_sp_privileges 将被设置为 OFF。If you start mysqld with --skip-new, automatic_sp_privileges is set to OFF.

    另请参见 第 27.2.2 节,“存储例程与 MySQL 权限”。See also Section 27.2.2, “Stored Routines and MySQL Privileges”.

  • auto_generate_certs

    命令行格式Command-Line Format --auto-generate-certs[={OFF|ON}]
    系统变量System Variable auto_generate_certs
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    此变量控制服务器是否在数据目录中自动生成 SSL 密钥和证书文件,如果它们尚不存在。This variable controls whether the server autogenerates SSL key and certificate files in the data directory, if they do not already exist.

    在启动时,如果启用了auto_generate_certs 系统变量,并且数据目录中缺少服务器端 SSL 文件,服务器会自动在数据目录中生成服务器端和客户端的 SSL 证书及密钥文件。在这种情况下,无论其他 TLS 选项的值如何,这些证书都会被生成。证书和密钥文件使客户端能够使用 SSL 进行安全连接;参见 第 8.3.1 节,“配置 MySQL 使用加密连接”。At startup, the server automatically generates server-side and client-side SSL certificate and key files in the data directory if the auto_generate_certs system variable is enabled and the server-side SSL files are missing from the data directory. These certificates are always generated in such cases, regardless of the values of any other TLS options. The certificate and key files enable secure client connections using SSL; see Section 8.3.1, “Configuring MySQL to Use Encrypted Connections”.

    关于 SSL 文件自动生成的更多信息,包括文件名和特性,请参见 第 8.3.3.1 节,“使用 MySQL 创建 SSL 和 RSA 证书及密钥”For more information about SSL file autogeneration, including file names and characteristics, see Section 8.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”

    sha256_password_auto_generate_rsa_keys 和 caching_sha2_password_auto_generate_rsa_keys 系统变量相关,但它们控制的是在未加密连接中使用 RSA 进行安全密码交换所需的 RSA 密钥对文件的自动生成。The sha256_password_auto_generate_rsa_keys and caching_sha2_password_auto_generate_rsa_keys system variables are related but control autogeneration of RSA key-pair files needed for secure password exchange using RSA over unencrypted connections.

  • back_log

    命令行格式Command-Line Format --back-log=#
    系统变量System Variable back_log
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1 (signifies autosizing; do not assign this literal value)
    最小值Minimum Value 1
    最大值Maximum Value 65535

    MySQL 可以处理的未完成连接请求的数量。当主 MySQL 线程在非常短的时间内收到很多连接请求时,这一参数就会起作用。然后主线程需要一些时间(虽然很短)来检查连接并启动新线程。back_log 值表示在 MySQL 暂时停止响应新请求之前,这段短时间内可以积压的请求数量。只有在您预计会在短时间内有大量连接时,才需要增加此值。The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time. It then takes some time (although very little) for the main thread to check the connection and start a new thread. The back_log value indicates how many requests can be stacked during this short time before MySQL momentarily stops answering new requests. You need to increase this only if you expect a large number of connections in a short period of time.

    换句话说,这个值是用于传入 TCP/IP 连接的侦听队列的大小。您的操作系统对该队列的大小有自己的限制。Unix listen() 系统调用的手册页应该有更多细节。请查阅您的操作系统文档以获取该变量的最大值。back_log 不能设置高于操作系统限制的值。In other words, this value is the size of the listen queue for incoming TCP/IP connections. Your operating system has its own limit on the size of this queue. The manual page for the Unix listen() system call should have more details. Check your OS documentation for the maximum value for this variable. back_log cannot be set higher than your operating system limit.

    默认值是 max_connections 的值,这允许允许的队列根据允许的最大连接数自动调整。The default value is the value of max_connections, which enables the permitted backlog to adjust to the maximum permitted number of connections.

  • basedir

    命令行格式Command-Line Format --basedir=dir_name--basedir=dir_name
    系统变量System Variable basedir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value parent of mysqld installation directoryparent of mysqld installation directory

    MySQL 安装基础目录的路径。The path to the MySQL installation base directory.

  • big_tables

    命令行格式Command-Line Format --big-tables[={OFF|ON}]
    系统变量System Variable big_tables
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果启用,服务器会将所有临时表存储在磁盘上,而不是内存中。这可以防止大多数需要大临时表的 SELECT 操作中出现 The table tbl_name is full 错误,但也会降低那些内存表就足够的查询的速度。If enabled, the server stores all temporary tables on disk rather than in memory. This prevents most The table tbl_name is full errors for SELECT operations that require a large temporary table, but also slows down queries for which in-memory tables would suffice.

    新连接的默认值是 OFF(使用内存临时表)。通常情况下,启用此变量是不必要的。当内存中的 内部 临时表由 TempTable 存储引擎(默认引擎)管理,并且 TempTable 存储引擎可以占用的最大内存量被超过时,TempTable 存储引擎会开始将数据存储到磁盘上的临时文件中。当内存中的临时表由 MEMORY 存储引擎管理时,内存表会根据需要自动转换为基于磁盘的表。更多信息请参见 第 10.4.4 节,“MySQL 中内部临时表的使用”。The default value for new connections is OFF (use in-memory temporary tables). Normally, it should never be necessary to enable this variable. When in-memory internal temporary tables are managed by the TempTable storage engine (the default), and the maximum amount of memory that can be occupied by the TempTable storage engine is exceeded, the TempTable storage engine starts storing data to temporary files on disk. When in-memory temporary tables are managed by the MEMORY storage engine, in-memory tables are automatically converted to disk-based tables as required. For more information, see Section 10.4.4, “Internal Temporary Table Use in MySQL”.

  • bind_address bind_address

    命令行格式Command-Line Format --bind-address=addr--bind-address=addr
    系统变量System Variable bind_addressbind_address
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value *

    MySQL 服务器在一个或多个网络套接字上监听 TCP/IP 连接。每个套接字绑定到一个地址,但一个地址可能映射到多个网络接口。要指定服务器应如何监听 TCP/IP 连接,请在服务器启动时设置 bind_address 系统变量。服务器还有一个 admin_address 系统变量,允许在专用接口上进行管理连接。参见 第 7.1.12.1 节,“连接接口”。The MySQL server listens on one or more network sockets for TCP/IP connections. Each socket is bound to one address, but it is possible for an address to map onto multiple network interfaces. To specify how the server should listen for TCP/IP connections, set the bind_address system variable at server startup. The server also has an admin_address system variable that enables administrative connections on a dedicated interface. See Section 7.1.12.1, “Connection Interfaces”.

    如果指定了bind_address,它接受一个或多个地址值的列表,每个地址值可以指定单个非通配符的 IP 地址或主机名。每个地址可能包含网络命名空间说明符。如果只指定一个地址,可以使用允许在多个网络接口上监听的通配符地址格式之一(*、0.0.0.0 或 ::)。多个地址用逗号分隔。列出多个值时,每个值必须指定单个非通配符 IP 地址(IPv4 或 IPv6)或主机名,并且不允许使用通配符地址格式(*、0.0.0.0 或 ::)。If bind_address is specified, it accepts a list of one or more address values, each of which may specify a single non-wildcard IP address or host name. Each address may include a network namespace specifier. If only one address is specified, it may make use of one of the wildcard address formats that permit listening on multiple network interfaces (*, 0.0.0.0, or ::). Multiple addresses are separated by commas. When multiple values are listed, each value must specify a single non-wildcard IP address (either IPv4 or IPv6) or a host name, and wildcard address formats (*, 0.0.0.0, or ::) are not allowed.

    IP 地址可以指定为 IPv4 或 IPv6 地址。对于任何作为主机名的值,服务器会将该名称解析为 IP 地址并绑定到该地址。如果主机名解析为多个 IP 地址,服务器会使用第一个 IPv4 地址(如果有的话),否则使用第一个 IPv6 地址。IP addresses can be specified as IPv4 or IPv6 addresses. For any value that is a host name, the server resolves the name to an IP address and binds to that address. If a host name resolves to multiple IP addresses, the server uses the first IPv4 address if there are any, or the first IPv6 address otherwise.

    服务器对不同类型的地址的处理如下:The server treats different types of addresses as follows:

    • 如果地址是 *,服务器将接受来自所有服务器主机 IPv4 接口的 TCP/IP 连接,如果服务器主机支持 IPv6,则也接受来自所有 IPv6 接口的连接。使用此地址可以允许所有服务器接口的 IPv4 和 IPv6 连接。该值为默认值。如果变量指定了多个值的列表,则不允许使用此值。If the address is *, the server accepts TCP/IP connections on all server host IPv4 interfaces, and, if the server host supports IPv6, on all IPv6 interfaces. Use this address to permit both IPv4 and IPv6 connections on all server interfaces. This value is the default. If the variable specifies a list of multiple values, this value is not permitted.

    • 如果地址是 0.0.0.0,服务器将接受来自所有服务器主机 IPv4 接口的 TCP/IP 连接。如果变量指定了多个值的列表,则不允许使用此值。If the address is 0.0.0.0, the server accepts TCP/IP connections on all server host IPv4 interfaces. If the variable specifies a list of multiple values, this value is not permitted.

    • 如果地址是 ::,服务器将接受来自所有服务器主机的 IPv4 和 IPv6 接口的 TCP/IP 连接。如果变量指定了多个值的列表,则不允许使用此值。If the address is ::, the server accepts TCP/IP connections on all server host IPv4 and IPv6 interfaces. If the variable specifies a list of multiple values, this value is not permitted.

    • 如果地址是 IPv4 映射地址,服务器接受该地址的 TCP/IP 连接,无论是 IPv4 还是 IPv6 格式。例如,如果服务器绑定到 ::ffff:127.0.0.1,客户端可以使用 --host=127.0.0.1 或 --host=::ffff:127.0.0.1 连接。If the address is an IPv4-mapped address, the server accepts TCP/IP connections for that address, in either IPv4 or IPv6 format. For example, if the server is bound to ::ffff:127.0.0.1, clients can connect using --host=127.0.0.1 or --host=::ffff:127.0.0.1.

    • 如果地址是“常规” IPv4 或 IPv6 地址(例如 127.0.0.1 或 ::1),服务器只接受针对该 IPv4 或 IPv6 地址的 TCP/IP 连接。If the address is a “regular” IPv4 or IPv6 address (such as 127.0.0.1 or ::1), the server accepts TCP/IP connections only for that IPv4 or IPv6 address.

    这些规则适用于为地址指定网络命名空间:These rules apply to specifying a network namespace for an address:

    • 可以为 IP 地址或主机名指定网络命名空间。A network namespace can be specified for an IP address or a host name.

    • 不能为通配符 IP 地址指定网络命名空间。A network namespace cannot be specified for a wildcard IP address.

    • 对于给定的地址,网络命名空间是可选的。如果提供,必须作为紧跟地址的一个/ns后缀来指定。For a given address, the network namespace is optional. If given, it must be specified as a /ns suffix immediately following the address.

    • 没有/ns后缀的地址使用主机系统的全局命名空间。因此,全局命名空间是默认值。An address with no /ns suffix uses the host system global namespace. The global namespace is therefore the default.

    • 带有/ns后缀的地址使用名为ns的命名空间。An address with a /ns suffix uses the namespace named ns.

    • 主机系统必须支持网络命名空间,并且每个命名的命名空间必须事先设置好。命名不存在的命名空间会产生错误。The host system must support network namespaces and each named namespace must previously have been set up. Naming a nonexistent namespace produces an error.

    • 如果变量值指定多个地址,它可以包含全局命名空间、命名命名空间中的地址,或混合地址。If the variable value specifies multiple addresses, it can include addresses in the global namespace, in named namespaces, or a mix.

    有关网络命名空间的更多信息,请参见第 7.1.14 节,“网络命名空间支持”。For additional information about network namespaces, see Section 7.1.14, “Network Namespace Support”.

    如果绑定任意地址失败,服务器会报错并无法启动。If binding to any address fails, the server produces an error and does not start.

    示例:Examples:

    • bind_address=*

      服务器监听所有 IPv4 或 IPv6 地址,由*通配符指定。The server listens on all IPv4 or IPv6 addresses, as specified by the * wildcard.

    • bind_address=198.51.100.20

      服务器仅监听198.51.100.20 IPv4 地址。The server listens only on the 198.51.100.20 IPv4 address.

    • bind_address=198.51.100.20,2001:db8:0:f101::1

      服务器监听198.51.100.20 IPv4 地址和2001:db8:0:f101::1 IPv6 地址。The server listens on the 198.51.100.20 IPv4 address and the 2001:db8:0:f101::1 IPv6 address.

    • bind_address=198.51.100.20,*

      命名多个值的列表时不允许使用通配符地址。bind_address如果你以This produces an error because wildcard addresses are not permitted when bind_address names a list of multiple values.

    • bind_address=198.51.100.20/red,2001:db8:0:f101::1/blue,192.0.2.50

      服务器在 red 命名空间中监听 198.51.100.20 IPv4 地址,在 blue 命名空间中监听 2001:db8:0:f101::1 IPv6 地址,在全局命名空间中监听 192.0.2.50 IPv4 地址。The server listens on the 198.51.100.20 IPv4 address in the red namespace, the 2001:db8:0:f101::1 IPv6 address in the blue namespace, and the 192.0.2.50 IPv4 address in the global namespace.

    当 bind_address 指定单个值(通配符或非通配符)时,服务器在单个套接字上监听,对于通配符地址,该套接字可能绑定到多个网络接口。当 bind_address 指定多个值的列表时,服务器为每个值监听一个套接字,每个套接字绑定到单个网络接口。套接字数量与指定值的数量成线性关系。根据操作系统接受连接的效率,较长的值列表可能会对接受 TCP/IP 连接的性能产生影响。When bind_address names a single value (wildcard or non-wildcard), the server listens on a single socket, which for a wildcard address may be bound to multiple network interfaces. When bind_address names a list of multiple values, the server listens on one socket per value, with each socket bound to a single network interface. The number of sockets is linear with the number of values specified. Depending on operating system connection-acceptance efficiency, long value lists might incur a performance penalty for accepting TCP/IP connections.

    由于文件描述符会分配给监听套接字和网络命名空间文件,因此可能需要增加 open_files_limit 系统变量。 Because file descriptors are allocated for listening sockets and network namespace files, it may be necessary to increase the open_files_limit system variable.

    如果您打算将服务器绑定到特定地址,请确保 mysql.user 系统表中包含一个具有管理权限的账户,以便您可以使用该账户连接到该地址。否则,您将无法关闭服务器。例如,如果您将服务器绑定到 *,您可以使用所有现有账户进行连接。但如果您将服务器绑定到 ::1,它只接受该地址的连接。在这种情况下,首先确保 'root'@'::1' 账户存在于 mysql.user 表中,以便您仍然可以连接到服务器并关闭它。If you intend to bind the server to a specific address, be sure that the mysql.user system table contains an account with administrative privileges that you can use to connect to that address. Otherwise, you cannot shut down the server. For example, if you bind the server to *, you can connect to it using all existing accounts. But if you bind the server to ::1, it accepts connections only on that address. In that case, first make sure that the 'root'@'::1' account is present in the mysql.user table so you can still connect to the server to shut it down.

  • block_encryption_mode

    命令行格式Command-Line Format --block-encryption-mode=#
    系统变量System Variable block_encryption_mode
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value aes-128-ecb

    该变量控制块加密算法(例如 AES)的块加密模式。它影响 AES_ENCRYPT() 和 AES_DECRYPT() 的加密。This variable controls the block encryption mode for block-based algorithms such as AES. It affects encryption for AES_ENCRYPT() and AES_DECRYPT().

    block_encryption_mode 的值采用 aes-keylen-mode 格式,其中 keylen 是密钥长度(以位为单位),mode 是加密模式。该值不区分大小写。允许的 keylen 值为 128、192 和 256。允许的 mode 值为 ECB、CBC、CFB1、CFB8、CFB128 和 OFB。block_encryption_mode takes a value in aes-keylen-mode format, where keylen is the key length in bits and mode is the encryption mode. The value is not case-sensitive. Permitted keylen values are 128, 192, and 256. Permitted mode values are ECB, CBC, CFB1, CFB8, CFB128, and OFB.

    例如,这条语句使 AES 加密函数使用 256 位的密钥长度和 CBC 模式:For example, this statement causes the AES encryption functions to use a key length of 256 bits and the CBC mode:

    SET block_encryption_mode = 'aes-256-cbc';
    

    尝试将 block_encryption_mode 设置为包含不支持的密钥长度或 SSL 库不支持的模式的值时,会发生错误。An error occurs for attempts to set block_encryption_mode to a value containing an unsupported key length or a mode that the SSL library does not support.

  • build_id

    系统变量System Variable build_id
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific Linux

    这是一个 160 位的SHA1签名,由链接器在 Linux 系统上使用-DWITH_BUILD_ID=ON(默认启用)编译服务器时生成,并转换为十六进制字符串。这个只读值作为唯一的构建 ID,并在启动时写入服务器日志。This is a 160-bit SHA1 signature which is generated by the linker when compiling the server on Linux systems with -DWITH_BUILD_ID=ON (enabled by default), and converted to a hexadecimal string. This read-only value serves as a unique build ID, and is written into the server log at startup.

    build_id在 Linux 以外的平台上不受支持。build_id is not supported on platforms other than Linux.

  • bulk_insert_buffer_size bulk_insert_buffer_size

    命令行格式Command-Line Format --bulk-insert-buffer-size=#
    系统变量System Variable bulk_insert_buffer_sizebulk_insert_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 8388608
    最小值Minimum Value 0
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295
    单位Unit 字节/线程bytes/thread

    MyISAM 使用一种特殊的树状缓存来加快在非空表中进行批量插入的速度,例如 INSERT ... SELECT、INSERT ... VALUES (...), (...), ... 以及 LOAD DATA。此变量限制每个线程缓存树的字节大小。将其设置为 0 将禁用此优化。默认值为 8MB。MyISAM uses a special tree-like cache to make bulk inserts faster for INSERT ... SELECT, INSERT ... VALUES (...), (...), ..., and LOAD DATA when adding data to nonempty tables. This variable limits the size of the cache tree in bytes per thread. Setting it to 0 disables this optimization. The default value is 8MB.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • caching_sha2_password_digest_rounds

    命令行格式Command-Line Format --caching-sha2-password-digest-rounds=#
    系统变量System Variable caching_sha2_password_digest_rounds
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 5000
    最小值Minimum Value 5000
    最大值Maximum Value 4095000

    caching_sha2_password 认证插件用于密码存储的哈希轮数。The number of hash rounds used by the caching_sha2_password authentication plugin for password storage.

    将哈希轮数增加到默认值以上会导致性能下降,这种下降与增加的数量成正比:Increasing the number of hashing rounds above the default value incurs a performance penalty that correlates with the amount of increase:

    • 创建使用 caching_sha2_password 插件的帐户不会影响创建该帐户的客户端会话,但服务器必须执行哈希轮次以完成操作。Creating an account that uses the caching_sha2_password plugin has no impact on the client session within which the account is created, but the server must perform the hashing rounds to complete the operation.

    • 对于使用该账户的客户端连接,服务器必须执行哈希轮次并将结果保存到缓存中。对于第一次客户端连接来说,登录时间会更长,但随后的连接则不会。这种行为会在每次服务器重启后发生。For client connections that use the account, the server must perform the hashing rounds and save the result in the cache. The result is longer login time for the first client connection, but not for subsequent connections. This behavior occurs after each server restart.

  • caching_sha2_password_auto_generate_rsa_keys

    命令行格式Command-Line Format --caching-sha2-password-auto-generate-rsa-keys[={OFF|ON}]--caching-sha2-password-auto-generate-rsa-keys[={OFF|ON}]
    系统变量System Variable caching_sha2_password_auto_generate_rsa_keys
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    服务器使用此变量来确定是否在数据目录中自动生成 RSA 私钥/公钥对文件,如果它们尚不存在。The server uses this variable to determine whether to autogenerate RSA private/public key-pair files in the data directory if they do not already exist.

    启动时,如果满足以下条件,服务器会自动在数据目录中生成 RSA 私钥/公钥对文件:sha256_password_auto_generate_rsa_keys 或 caching_sha2_password_auto_generate_rsa_keys系统变量被启用;未指定 RSA 选项;RSA 文件在数据目录中缺失。这些密钥对文件允许通过 RSA 通过未加密连接安全交换密码,用于由sha256_password(弃用)或caching_sha2_password;参见 第 8.4.1.3 节,“SHA-256 可插拔认证”,以及 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。At startup, the server automatically generates RSA private/public key-pair files in the data directory if all of these conditions are true: The sha256_password_auto_generate_rsa_keys or caching_sha2_password_auto_generate_rsa_keys system variable is enabled; no RSA options are specified; the RSA files are missing from the data directory. These key-pair files enable secure password exchange using RSA over unencrypted connections for accounts authenticated by the sha256_password (deprecated) or caching_sha2_password plugin; see Section 8.4.1.3, “SHA-256 Pluggable Authentication”, and Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.

    有关 RSA 文件自动生成的更多信息,包括文件名称和特性,请参阅 第 8.3.3.1 节,“使用 MySQL 创建 SSL 和 RSA 证书及密钥”For more information about RSA file autogeneration, including file names and characteristics, see Section 8.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”

    auto_generate_certs 系统变量相关,但它控制的是使用 SSL 进行安全连接所需的 SSL 证书和密钥文件的自动生成。The auto_generate_certs system variable is related but controls autogeneration of SSL certificate and key files needed for secure connections using SSL.

  • caching_sha2_password_private_key_path

    命令行格式Command-Line Format --caching-sha2-password-private-key-path=file_name--caching-sha2-password-private-key-path=file_name
    系统变量System Variable caching_sha2_password_private_key_path
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value private_key.pem

    此变量指定用于 caching_sha2_password 身份验证插件的 RSA 私钥文件的路径名称。如果文件以相对路径命名,则相对于服务器数据目录进行解析。该文件必须为 PEM 格式。This variable specifies the path name of the RSA private key file for the caching_sha2_password authentication plugin. If the file is named as a relative path, it is interpreted relative to the server data directory. The file must be in PEM format.

    Important

    因为此文件存储了私钥,其访问模式应受到限制,以便只有 MySQL 服务器可以读取它。Because this file stores a private key, its access mode should be restricted so that only the MySQL server can read it.

    有关 caching_sha2_password 的信息,请参见 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。For information about caching_sha2_password, see Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.

  • caching_sha2_password_public_key_path

    命令行格式Command-Line Format --caching-sha2-password-public-key-path=file_name--caching-sha2-password-public-key-path=file_name
    系统变量System Variable caching_sha2_password_public_key_path
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value public_key.pem

    该变量指定用于 caching_sha2_password 身份验证插件的 RSA 公钥文件的路径名。如果文件名是相对路径,它将相对于服务器数据目录进行解释。该文件必须为 PEM 格式。This variable specifies the path name of the RSA public key file for the caching_sha2_password authentication plugin. If the file is named as a relative path, it is interpreted relative to the server data directory. The file must be in PEM format.

    有关 caching_sha2_password 的信息,包括客户端如何请求 RSA 公钥的信息,请参见 第 8.4.1.2 节,“缓存 SHA-2 可插拔身份验证”。For information about caching_sha2_password, including information about how clients request the RSA public key, see Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.

  • character_set_client

    系统变量System Variable character_set_client
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4utf8mb4

    来自客户端的语句的字符集。该变量的会话值是根据客户端连接到服务器时请求的字符集设置的。(许多客户端支持 --default-character-set 选项,以便显式指定此字符集。另请参见 第 12.4 节,“连接字符集和排序规则”。)当客户端请求的值未知或不可用,或者服务器配置为忽略客户端请求时,将使用该变量的全局值来设置会话值。当客户端请求服务器未知的字符集时,就会发生这种情况,例如,当一个支持日语的客户端在连接到未配置 sjis 支持的服务器时请求 sjis。The character set for statements that arrive from the client. The session value of this variable is set using the character set requested by the client when the client connects to the server. (Many clients support a --default-character-set option to enable this character set to be specified explicitly. See also Section 12.4, “Connection Character Sets and Collations”.) The global value of the variable is used to set the session value in cases when the client-requested value is unknown or not available, or the server is configured to ignore client requests. This can happen when the client requests a character set not known to the server, such as when a Japanese-enabled client requests sjis when connecting to a server not configured with sjis support.

    某些字符集不能用作客户端字符集。尝试将它们用作 character_set_client 值会产生错误。请参阅 不允许的客户端字符集。Some character sets cannot be used as the client character set. Attempting to use them as the character_set_client value produces an error. See Impermissible Client Character Sets.

  • character_set_connection

    系统变量System Variable character_set_connection
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4utf8mb4

    用于未指定字符集引入符的字符串字面量以及数字到字符串转换的字符集。有关引入符的信息,请参见 第 12.3.8 节,“字符集引入符”。The character set used for literals specified without a character set introducer and for number-to-string conversion. For information about introducers, see Section 12.3.8, “Character Set Introducers”.

  • character_set_database

    系统变量System Variable character_set_database
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4utf8mb4
    脚注Footnote 此选项是动态的,但应仅由服务器设置。您不应手动设置此变量。This option is dynamic, but should be set only by server. You should not set this variable manually.

    默认数据库使用的字符集。每当默认数据库更改时,服务器会设置此变量。如果没有默认数据库,该变量的值与character_set_server相同。The character set used by the default database. The server sets this variable whenever the default database changes. If there is no default database, the variable has the same value as character_set_server.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

    全局 character_set_database 和 collation_database 系统变量已被弃用;预计将在未来的 MySQL 版本中移除。The global character_set_database and collation_database system variables are deprecated; expect them to be removed in a future version of MySQL.

    为会话 character_set_database 和 collation_database 系统变量分配值已被弃用,分配操作会产生警告。预计在未来的 MySQL 版本中,这些会话变量将变为只读(对它们的分配将产生错误),但仍可以访问这些会话变量以确定默认数据库的字符集和排序规则。Assigning a value to the session character_set_database and collation_database system variables is deprecated and assignments produce a warning. Expect the session variables to become read-only (and assignments to them to produce an error) in a future version of MySQL in which it remains possible to access the session variables to determine the database character set and collation for the default database.

  • character_set_filesystem

    命令行格式Command-Line Format --character-set-filesystem=name
    系统变量System Variable character_set_filesystem
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value binarybinary

    文件系统字符集。该变量用于解释指向文件名的字符串字面值,例如在LOAD DATA和SELECT ... INTO OUTFILE语句以及LOAD_FILE()函数中。在尝试打开文件之前,这些文件名会从character_set_client转换为character_set_filesystem。默认值是binary,这意味着不会进行转换。对于允许多字节文件名的系统,可能需要设置不同的值。例如,如果系统使用 UTF-8 表示文件名,则将character_set_filesystem设置为'utf8mb4'。The file system character set. This variable is used to interpret string literals that refer to file names, such as in the LOAD DATA and SELECT ... INTO OUTFILE statements and the LOAD_FILE() function. Such file names are converted from character_set_client to character_set_filesystem before the file opening attempt occurs. The default value is binary, which means that no conversion occurs. For systems on which multibyte file names are permitted, a different value may be more appropriate. For example, if the system represents file names using UTF-8, set character_set_filesystem to 'utf8mb4'.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • character_set_results

    系统变量System Variable character_set_results
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4utf8mb4

    用于将查询结果返回给客户端的字符集。这包括结果数据,如列值,结果元数据,如列名,以及错误消息。The character set used for returning query results to the client. This includes result data such as column values, result metadata such as column names, and error messages.

  • character_set_server

    命令行格式Command-Line Format --character-set-server=name
    系统变量System Variable character_set_server
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4utf8mb4

    服务器的默认字符集。参见 第 12.15 节,“字符集配置”。如果设置此变量,你也应该设置 collation_server 来指定字符集的校对规则。The servers default character set. See Section 12.15, “Character Set Configuration”. If you set this variable, you should also set collation_server to specify the collation for the character set.

  • character_set_system

    系统变量System Variable character_set_system
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb3

    服务器用于存储标识符的字符集。该值始终为 utf8mb3。The character set used by the server for storing identifiers. The value is always utf8mb3.

  • character_sets_dir

    命令行格式Command-Line Format --character-sets-dir=dir_name--character-sets-dir=dir_name
    系统变量System Variable character_sets_dir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    安装字符集的目录。请参见第 12.15 节,“字符集配置”。The directory where character sets are installed. See Section 12.15, “Character Set Configuration”.

  • check_proxy_users

    命令行格式Command-Line Format --check-proxy-users[={OFF|ON}]--check-proxy-users[={OFF|ON}]
    系统变量System Variable check_proxy_users
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    一些认证插件为自己实现了代理用户映射(例如,PAM 和 Windows 认证插件)。其他认证插件默认不支持代理用户。在这些插件中,有些可以请求 MySQL 服务器根据授予的代理权限映射代理用户:mysql_native_password(已弃用)、sha256_password(已弃用)。Some authentication plugins implement proxy user mapping for themselves (for example, the PAM and Windows authentication plugins). Other authentication plugins do not support proxy users by default. Of these, some can request that the MySQL server itself map proxy users according to granted proxy privileges: mysql_native_password (deprecated), sha256_password (deprecated).

    如果启用了 check_proxy_users 系统变量,服务器会为任何提出此类请求的认证插件执行代理用户映射。为了利用服务器的代理用户映射支持,可能还需要启用插件特定的系统变量:If the check_proxy_users system variable is enabled, the server performs proxy user mapping for any authentication plugins that make such a request. It may also be necessary to enable plugin-specific system variables to take advantage of server proxy user mapping support:

    有关用户代理的信息,请参阅 第 8.2.19 节,“代理用户”。For information about user proxying, see Section 8.2.19, “Proxy Users”.

  • collation_connection

    系统变量System Variable collation_connection
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    连接字符集的排序规则。collation_connection 对字面字符串的比较非常重要。对于与列值的字符串比较,collation_connection 并不重要,因为列有自己的排序规则,其排序优先级更高(参见 第 12.8.4 节,“表达式中的排序规则可强制性”)。The collation of the connection character set. collation_connection is important for comparisons of literal strings. For comparisons of strings with column values, collation_connection does not matter because columns have their own collation, which has a higher collation precedence (see Section 12.8.4, “Collation Coercibility in Expressions”).

    为此变量使用用户定义排序规则的名称会引发警告。Using the name of a user-defined collation for this variable raises a warning.

  • collation_database collation_database

    系统变量System Variable collation_databasecollation_database
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4_0900_ai_ciutf8mb4_0900_ai_ci
    脚注Footnote 此选项是动态的,但应仅由服务器设置。您不应手动设置此变量。This option is dynamic, but should be set only by server. You should not set this variable manually.

    默认数据库使用的排序规则。每当默认数据库更改时,服务器会设置此变量。如果没有默认数据库,该变量的值与 collation_server 相同。The collation used by the default database. The server sets this variable whenever the default database changes. If there is no default database, the variable has the same value as collation_server.

    全局 character_set_database 和 collation_database 系统变量已被弃用;预计将在未来的 MySQL 版本中移除。The global character_set_database and collation_database system variables are deprecated; expect them to be removed in a future version of MySQL.

    为会话 character_set_database 和 collation_database 系统变量分配值已被弃用,分配操作会产生警告。预期在 MySQL 的未来版本中,这些会话变量将变为只读(分配操作会产生错误),但仍可以访问会话变量以确定默认数据库的字符集和排序规则。Assigning a value to the session character_set_database and collation_database system variables is deprecated and assignments produce a warning. Expect the session variables to become read-only (and assignments to produce an error) in a future version of MySQL in which it remains possible to access the session variables to determine the database character set and collation for the default database.

    使用用户定义的排序规则名称为 collation_database 会触发警告。Using the name of a user-defined collation for collation_database raises a warning.

  • collation_server

    命令行格式Command-Line Format --collation-server=name
    系统变量System Variable collation_server
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value utf8mb4_0900_ai_ciutf8mb4_0900_ai_ci

    服务器的默认校对规则。参见 第 12.15 节,“字符集配置”。The server's default collation. See Section 12.15, “Character Set Configuration”.

    将此设置为用户定义的排序规则名称会引发警告。Setting this to the name of a user-defined collation raises a warning.

  • completion_type

    命令行格式Command-Line Format --completion-type=#
    系统变量System Variable completion_type
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value NO_CHAINNO_CHAIN
    有效值Valid Values

    NO_CHAINNO_CHAIN

    CHAINCHAIN

    RELEASERELEASE

    0

    1

    2

    事务完成类型。该变量可以采用下表所示的值。该变量可以使用名称值或相应的整数值进行赋值。The transaction completion type. This variable can take the values shown in the following table. The variable can be assigned using either the name values or corresponding integer values.

    价值Value 说明Description
    NO_CHAIN(或 0)NO_CHAIN (or 0) COMMIT 和 ROLLBACK 不受影响。这是默认值。COMMIT and ROLLBACK are unaffected. This is the default value.
    CHAIN(或 1)CHAIN (or 1) COMMIT 和 ROLLBACK 分别相当于 COMMIT AND CHAIN 和 ROLLBACK AND CHAIN。(新事务会立即开始,并与刚结束事务具有相同的隔离级别。)COMMIT and ROLLBACK are equivalent to COMMIT AND CHAIN and ROLLBACK AND CHAIN, respectively. (A new transaction starts immediately with the same isolation level as the just-terminated transaction.)
    RELEASE(或 2)RELEASE (or 2) COMMIT 和 ROLLBACK 分别等同于 COMMIT RELEASE 和 ROLLBACK RELEASE。(事务终止后服务器会断开连接。)COMMIT and ROLLBACK are equivalent to COMMIT RELEASE and ROLLBACK RELEASE, respectively. (The server disconnects after terminating the transaction.)

    completion_type 影响以 START TRANSACTION 或 BEGIN并以COMMIT 或 ROLLBACK。它不适用于执行第 15.3.3 节,“导致隐式提交的语句”中列出的语句执行而产生的隐式提交。同样不适用于XA COMMIT XA ROLLBACK),或当 autocommit=1。completion_type affects transactions that begin with START TRANSACTION or BEGIN and end with COMMIT or ROLLBACK. It does not apply to implicit commits resulting from execution of the statements listed in Section 15.3.3, “Statements That Cause an Implicit Commit”. It also does not apply for XA COMMIT, XA ROLLBACK, or when autocommit=1.

  • component_scheduler.enabled

    命令行格式Command-Line Format --component-scheduler.enabled[=value]--component-scheduler.enabled[=value]
    系统变量System Variable component_scheduler.enabled
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    在启动时设置为OFF时,后台线程不会启动。任务仍然可以被调度,但它们不会运行,直到component_scheduler被启用。在启动时设置为ON时,该组件完全可用。When set to OFF at startup, the background thread does not start. Tasks can still be scheduled, but they do not run until component_scheduler is enabled. When set to ON at startup, the component is fully operational.

    也可以动态设置该值以获得以下效果:It is also possible to set the value dynamically to get the following effects:

    • ON 启动后台线程,立即开始处理队列。ON starts the background thread that begins servicing the queue immediately.

    • OFF 发出终止后台线程的信号,并等待其结束。后台线程在访问队列以检查要执行的任务之前会检查终止标志。OFF signals a termination of the background thread, which waits for it to end. The background thread checks the termination flag before accessing the queue to check for tasks to execute.

  • concurrent_insert

    命令行格式Command-Line Format --concurrent-insert[=value]
    系统变量System Variable concurrent_insert
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value AUTOAUTO
    有效值Valid Values

    NEVERNEVER

    AUTOAUTO

    ALWAYS 总是ALWAYS

    0

    1

    2

    如果是 AUTO(默认值),MySQL 允许在 MyISAM 表中同时运行 INSERT 和 SELECT 语句,这些表在数据文件的中间没有空闲块。If AUTO (the default), MySQL permits INSERT and SELECT statements to run concurrently for MyISAM tables that have no free blocks in the middle of the data file.

    该变量可以取下表所示的值。变量可以使用名称值或相应的整数值进行赋值。This variable can take the values shown in the following table. The variable can be assigned using either the name values or corresponding integer values.

    价值Value 说明Description
    NEVER(或 0)NEVER (or 0) 禁用并发插入Disables concurrent inserts
    AUTO(或 1)AUTO (or 1) (默认)启用对没有空洞的MyISAM表的并发插入(Default) Enables concurrent insert for MyISAM tables that do not have holes
    ALWAYS(或 2)ALWAYS (or 2) 允许对所有MyISAM表进行并发插入,即使表中有空洞。对于有空洞的表,如果表正在被另一个线程使用,新行将插入表的末尾。否则,MySQL 将获取正常写锁并将新行插入空洞中。Enables concurrent inserts for all MyISAM tables, even those that have holes. For a table with a hole, new rows are inserted at the end of the table if it is in use by another thread. Otherwise, MySQL acquires a normal write lock and inserts the row into the hole.

    开始mysqld设置为--skip-new, concurrent_insert用于NEVER.If you start mysqld with --skip-new, concurrent_insert is set to NEVER.

    另见 第 10.11.3 节,“并发插入”。See also Section 10.11.3, “Concurrent Inserts”.

  • connect_timeout

    命令行格式Command-Line Format --connect-timeout=#
    系统变量System Variable connect_timeout
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 10
    最小值Minimum Value 2
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    mysqld 服务器在响应 Bad handshake 之前等待连接数据包的秒数。默认值为 10 秒。The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. The default value is 10 seconds.

    如果客户端经常遇到类似 connect_timeout 的错误,增加 Lost connection to MySQL server at 'XXX', system error: errno 的值可能会有所帮助。Increasing the connect_timeout value might help if clients frequently encounter errors of the form Lost connection to MySQL server at 'XXX', system error: errno.

  • connection_memory_chunk_size

    命令行格式Command-Line Format --connection-memory-chunk-size=#
    系统变量System Variable connection_memory_chunk_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8192
    最小值Minimum Value 0
    最大值Maximum Value 536870912
    单位Unit 字节bytes

    设置全局内存使用计数器 Global_connection_memory 更新的分块大小。只有当所有用户连接的总内存消耗变化超过此数值时,状态变量才会更新。通过设置 connection_memory_chunk_size = 0 来禁用更新。Set the chunking size for updates to the global memory usage counter Global_connection_memory. The status variable is updated only when total memory consumption by all user connections changes by more than this amount. Disable updates by setting connection_memory_chunk_size = 0.

    内存计算不包括系统用户(如 MySQL root 用户)使用的内存。InnoDB 缓冲池使用的内存也不包括在内。The memory calculation is exclusive of any memory used by system users such as the MySQL root user. Memory used by the InnoDB buffer pool is also not included.

    您必须拥有 SYSTEM_VARIABLES_ADMIN 或 SUPER 权限才能设置此变量。You must have the SYSTEM_VARIABLES_ADMIN or SUPER privilege to set this variable.

  • connection_memory_limit

    命令行格式Command-Line Format --connection-memory-limit=#
    系统变量System Variable connection_memory_limit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 18446744073709551615
    最小值Minimum Value 2097152
    最大值Maximum Value 18446744073709551615
    单位Unit 字节bytes

    设置单个用户连接可以使用的最大内存量。如果任何用户连接使用的内存超过此数量,该连接的所有查询将被拒绝,并返回 ER_CONN_LIMIT,包括当前正在运行的任何查询。Set the maximum amount of memory that can be used by a single user connection. If any user connection uses more than this amount, all queries from this connection are rejected with ER_CONN_LIMIT, including any queries currently running.

    此变量设置的限制不适用于系统用户或 MySQL root 账户。InnoDB 缓冲池使用的内存也不包含在内。The limit set by this variable does not apply to system users, or to the MySQL root account. Memory used by the InnoDB buffer pool is also not included.

    您必须拥有 SYSTEM_VARIABLES_ADMIN 或 SUPER 权限才能设置此变量。You must have the SYSTEM_VARIABLES_ADMIN or SUPER privilege to set this variable.

  • core_file

    系统变量System Variable core_file
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    当服务器意外退出时是否写入核心文件。此变量由 --core-file 选项设置。Whether to write a core file if the server unexpectedly exits. This variable is set by the --core-file option.

  • create_admin_listener_thread

    命令行格式Command-Line Format --create-admin-listener-thread[={OFF|ON}]
    系统变量System Variable create_admin_listener_thread
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    是否为管理网络接口上的客户端连接使用专用监听线程(参见第 7.1.12.1 节,“连接接口”)。默认值为OFF;即主接口上的普通连接的管理线程也处理管理接口的连接。Whether to use a dedicated listening thread for client connections on the administrative network interface (see Section 7.1.12.1, “Connection Interfaces”). The default is OFF; that is, the manager thread for ordinary connections on the main interface also handles connections for the administrative interface.

    根据平台类型和工作负载等因素,你可能会发现某个变量设置比另一个设置更能带来更好的性能。Depending on factors such as platform type and workload, you may find one setting for this variable yields better performance than the other setting.

    如果未指定 admin_address,则设置 create_admin_listener_thread 将无效,因为在这种情况下,服务器不会维护任何管理网络接口。Setting create_admin_listener_thread has no effect if admin_address is not specified because in that case the server maintains no administrative network interface.

  • cte_max_recursion_depth

    命令行格式Command-Line Format --cte-max-recursion-depth=#
    系统变量System Variable cte_max_recursion_depth
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1000
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    公共表表达式(CTE)的最大递归深度。服务器将终止执行任何递归层数超过该变量值的 CTE。有关更多信息,请参见 限制公共表表达式递归。The common table expression (CTE) maximum recursion depth. The server terminates execution of any CTE that recurses more levels than the value of this variable. For more information, see Limiting Common Table Expression Recursion.

  • datadir

    命令行格式Command-Line Format --datadir=dir_name--datadir=dir_name
    系统变量System Variable datadir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    MySQL 服务器数据目录的路径。相对路径相对于当前目录进行解析。如果您希望服务器自动启动(即在无法预先知道当前目录的环境中),最好将 datadir 值指定为绝对路径。The path to the MySQL server data directory. Relative paths are resolved with respect to the current directory. If you expect the server to be started automatically (that is, in contexts for which you cannot know the current directory in advance), it is best to specify the datadir value as an absolute path.

  • debug

    命令行格式Command-Line Format --debug[=debug_options]--debug[=debug_options]
    系统变量System Variable debugdebug
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值(Unix)Default Value (Unix) d:t:i:o,/tmp/mysqld.trace
    默认值(Windows)Default Value (Windows) d:t:i:O,\mysqld.trace

    此变量指示当前的调试设置。它仅适用于启用调试支持构建的服务器。初始值来自服务器启动时提供的 --debug 选项的值。全局值和会话值可以在运行时设置。This variable indicates the current debugging settings. It is available only for servers built with debugging support. The initial value comes from the value of instances of the --debug option given at server startup. The global and session values may be set at runtime.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

    分配以 + 或 - 开头的值会导致该值被加到或从当前值中减去:Assigning a value that begins with + or - cause the value to added to or subtracted from the current value:

    mysql> SET debug = 'T';
    mysql> SELECT @@debug;
    +---------+
    | @@debug |
    +---------+
    | T       |
    +---------+
    
    mysql> SET debug = '+P';
    mysql> SELECT @@debug;
    +---------+
    | @@debug |
    +---------+
    | P:T     |
    +---------+
    
    mysql> SET debug = '-P';
    mysql> SELECT @@debug;
    +---------+
    | @@debug |
    +---------+
    | T       |
    +---------+
    

    更多信息,请参阅 第 7.9.4 节,“DBUG 包”。For more information, see Section 7.9.4, “The DBUG Package”.

  • debug_sync

    系统变量System Variable debug_sync
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    此变量是调试同步功能的用户界面。使用调试同步功能要求 MySQL 使用 -DWITH_DEBUG=ON CMake 选项进行配置(参见 第 2.8.7 节,“MySQL 源代码配置选项”);否则,此系统变量不可用。This variable is the user interface to the Debug Sync facility. Use of Debug Sync requires that MySQL be configured with the -DWITH_DEBUG=ON CMake option (see Section 2.8.7, “MySQL Source-Configuration Options”); otherwise, this system variable is not available.

    全局变量的值是只读的,用于指示该功能是否启用。默认情况下,调试同步(Debug Sync)是禁用的,debug_sync 的值为 OFF。如果服务器使用 --debug-sync-timeout=N 启动,其中 N 是大于 0 的超时时间值,则调试同步被启用,debug_sync 的值为 ON - current signal,后跟信号名称。同时,N 成为各个同步点的默认超时时间。The global variable value is read only and indicates whether the facility is enabled. By default, Debug Sync is disabled and the value of debug_sync is OFF. If the server is started with --debug-sync-timeout=N, where N is a timeout value greater than 0, Debug Sync is enabled and the value of debug_sync is ON - current signal followed by the signal name. Also, N becomes the default timeout for individual synchronization points.

    会话值可以被任何用户读取,并且与全局变量具有相同的值。可以设置会话值以控制同步点。The session value can be read by any user and has the same value as the global variable. The session value can be set to control synchronization points.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

    有关调试同步工具以及如何使用同步点的说明,请参阅 MySQL 内部结构:测试同步。For a description of the Debug Sync facility and how to use synchronization points, see MySQL Internals: Test Synchronization.

  • default_collation_for_utf8mb4

    系统变量System Variable default_collation_for_utf8mb4
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value utf8mb4_0900_ai_ciutf8mb4_0900_ai_ci
    有效值Valid Values

    utf8mb4_0900_ai_ciutf8mb4_0900_ai_ci

    utf8mb4_general_ci

    Important

    default_collation_for_utf8mb4 系统变量仅供 MySQL 复制内部使用。The default_collation_for_utf8mb4 system variable is for internal use by MySQL Replication only.

    服务器将该变量设置为 utf8mb4 字符集的默认排序。变量的值会从源复制到副本,以便副本能够正确处理来自源的数据,而 utf8mb4不同。该变量主要用于支持从 MySQL 5.7 或更早的复制源服务器到较晚的 MySQL 副本服务器,或带有 MySQL 5.7 主节点和一个或多个 MySQL 8.0 或更新次级服务器的组复制。MySQL 5.7 中 utf8mb4是 utf8mb4_general_ci,但在后续版本系列中为 utf8mb4_0900_ai_ci。该变量不存在于 MySQL 8.0 之前的版本,因此如果副本没有收到该变量的值,它会假设源代码来自更早版本,并将该值设置为之前的默认排序utf8mb4_general_ci。This variable is set by the server to the default collation for the utf8mb4 character set. The value of the variable is replicated from a source to a replica so that the replica can correctly process data originating from a source with a different default collation for utf8mb4. This variable is primarily intended to support replication from a MySQL 5.7 or older replication source server to a later MySQL replica server, or group replication with a MySQL 5.7 primary node and one or more MySQL 8.0 or later secondaries. The default collation for utf8mb4 in MySQL 5.7 is utf8mb4_general_ci, but utf8mb4_0900_ai_ci in later release series. The variable is not present in releases earlier than MySQL 8.0, so if the replica does not receive a value for the variable, it assumes the source is from an earlier release and sets the value to the previous default collation utf8mb4_general_ci.

    以下语句中使用默认的 utf8mb4 排序规则:The default utf8mb4 collation is used in the following statements:

    另请参见 第 12.9 节,“Unicode 支持”。See also Section 12.9, “Unicode Support”.

  • default_password_lifetime

    命令行格式Command-Line Format --default-password-lifetime=#
    系统变量System Variable default_password_lifetime
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 65535
    单位Unit 天days

    此变量定义了全局自动密码过期策略。默认的 default_password_lifetime 值为 0,这将禁用自动密码过期。如果 default_password_lifetime 的值为正整数 N,则表示允许的密码有效期;密码必须每 N 天更改一次。This variable defines the global automatic password expiration policy. The default default_password_lifetime value is 0, which disables automatic password expiration. If the value of default_password_lifetime is a positive integer N, it indicates the permitted password lifetime; passwords must be changed every N days.

    可以使用 CREATE USER 和 ALTER USER 语句的密码过期选项,根据需要覆盖全局密码过期策略。请参阅 第 8.2.15 节,“密码管理”。The global password expiration policy can be overridden as desired for individual accounts using the password expiration option of the CREATE USER and ALTER USER statements. See Section 8.2.15, “Password Management”.

  • default_storage_engine

    命令行格式Command-Line Format --default-storage-engine=name
    系统变量System Variable default_storage_engine
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value InnoDB

    表的默认存储引擎。参见 第 18 章,其他存储引擎。此变量仅设置永久表的存储引擎。要设置TEMPORARY表的存储引擎,请设置default_tmp_storage_engine系统变量。The default storage engine for tables. See Chapter 18, Alternative Storage Engines. This variable sets the storage engine for permanent tables only. To set the storage engine for TEMPORARY tables, set the default_tmp_storage_engine system variable.

    要查看哪些存储引擎可用和启用,请使用 SHOW ENGINES 语句或查询 INFORMATION_SCHEMA ENGINES 表。To see which storage engines are available and enabled, use the SHOW ENGINES statement or query the INFORMATION_SCHEMA ENGINES table.

    如果在服务器启动时禁用默认存储引擎,必须为永久表和 TEMPORARY 表设置不同的默认引擎,否则服务器无法启动。If you disable the default storage engine at server startup, you must set the default engine for both permanent and TEMPORARY tables to a different engine, or else the server does not start.

  • default_table_encryption

    命令行格式Command-Line Format --default-table-encryption[={OFF|ON}]
    系统变量System Variable default_table_encryption
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    定义在创建模式和通用表空间时,如果未指定ENCRYPTION子句,所应用的默认加密设置。Defines the default encryption setting applied to schemas and general tablespaces when they are created without specifying an ENCRYPTION clause.

    default_table_encryption变量仅适用于用户创建的模式和通用表空间。它不管理mysql系统表空间的加密。The default_table_encryption variable is only applicable to user-created schemas and general tablespaces. It does not govern encryption of the mysql system tablespace.

    设置 default_table_encryption 的运行时值需要 SYSTEM_VARIABLES_ADMIN 和 TABLE_ENCRYPTION_ADMIN 权限,或者已弃用的 SUPER 权限。Setting the runtime value of default_table_encryption requires the SYSTEM_VARIABLES_ADMIN and TABLE_ENCRYPTION_ADMIN privileges, or the deprecated SUPER privilege.

    在 Group Replication 运行时,default_table_encryption 的值无法更改。The value of default_table_encryption cannot be changed while Group Replication is running.

    default_table_encryption 支持 SET PERSIST 和 SET PERSIST_ONLY 语法。参见 第 7.1.9.3 节,“持久化系统变量”。default_table_encryption supports SET PERSIST and SET PERSIST_ONLY syntax. See Section 7.1.9.3, “Persisted System Variables”.

    更多信息,请参见 为模式和通用表空间定义加密默认值。For more information, see Defining an Encryption Default for Schemas and General Tablespaces.

  • default_tmp_storage_engine

    命令行格式Command-Line Format --default-tmp-storage-engine=name
    系统变量System Variable default_tmp_storage_engine
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 枚举Enumeration
    默认值Default Value InnoDB

    TEMPORARY 表(使用 CREATE TEMPORARY TABLE 创建)的默认存储引擎。要设置永久表的存储引擎,请设置 default_storage_engine 系统变量。另请参阅该变量的讨论以了解可能的取值。The default storage engine for TEMPORARY tables (created with CREATE TEMPORARY TABLE). To set the storage engine for permanent tables, set the default_storage_engine system variable. Also see the discussion of that variable regarding possible values.

    如果在服务器启动时禁用默认存储引擎,必须为永久表和 TEMPORARY 表设置不同的默认引擎,否则服务器无法启动。If you disable the default storage engine at server startup, you must set the default engine for both permanent and TEMPORARY tables to a different engine, or else the server does not start.

  • default_week_format

    命令行格式Command-Line Format --default-week-format=#
    系统变量System Variable default_week_format
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 7

    的默认模式值WEEK()函数。请参见第 14.7 节,“日期和时间函数”.The default mode value to use for the WEEK() function. See Section 14.7, “Date and Time Functions”.

  • delay_key_write

    命令行格式Command-Line Format --delay-key-write[={OFF|ON|ALL}]
    系统变量System Variable delay_key_write
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value ONON
    有效值Valid Values

    OFFOFF

    ONON

    ALLALL

    该变量指定如何使用延迟键写入。它仅适用于MyISAM表。延迟键写入会导致键缓冲区在写入之间不被刷新。另请参阅18.2.1 节,“MyISAM 启动选项”。This variable specifies how to use delayed key writes. It applies only to MyISAM tables. Delayed key writing causes key buffers not to be flushed between writes. See also Section 18.2.1, “MyISAM Startup Options”.

    此变量可以取以下值之一,以影响可在DELAY_KEY_WRITE语句中使用的CREATE TABLE表选项的处理方式。This variable can have one of the following values to affect handling of the DELAY_KEY_WRITE table option that can be used in CREATE TABLE statements.

    选项Option 说明Description
    OFFOFF DELAY_KEY_WRITE 被忽略。DELAY_KEY_WRITE is ignored.
    ONON MySQL 会遵循在 CREATE TABLE 语句中指定的任何 DELAY_KEY_WRITE 选项。这是默认值。MySQL honors any DELAY_KEY_WRITE option specified in CREATE TABLE statements. This is the default value.
    ALLALL 所有新打开的表都被视为已启用 DELAY_KEY_WRITE 选项创建。All new opened tables are treated as if they were created with the DELAY_KEY_WRITE option enabled.
    Note

    如果您将此变量设置为 ALL,则在表正在使用时不应从其他程序(例如另一个 MySQL 服务器或 myisamchk)使用 MyISAM 表。这样做会导致索引损坏。If you set this variable to ALL, you should not use MyISAM tables from within another program (such as another MySQL server or myisamchk) when the tables are in use. Doing so leads to index corruption.

    如果为某个表启用了 DELAY_KEY_WRITE,则在每次索引更新时不会刷新该表的键缓冲区,而仅在表关闭时刷新。这大大加快了键的写入速度,但如果使用此功能,应该通过在启动服务器时设置 myisam_recover_options 系统变量来自动检查所有 MyISAM 表(例如,myisam_recover_options='BACKUP,FORCE')。参见 第 7.1.8 节,“服务器系统变量”,以及 第 18.2.1 节,“MyISAM 启动选项”。If DELAY_KEY_WRITE is enabled for a table, the key buffer is not flushed for the table on every index update, but only when the table is closed. This speeds up writes on keys a lot, but if you use this feature, you should add automatic checking of all MyISAM tables by starting the server with the myisam_recover_options system variable set (for example, myisam_recover_options='BACKUP,FORCE'). See Section 7.1.8, “Server System Variables”, and Section 18.2.1, “MyISAM Startup Options”.

    如果你使用 mysqld 并带上 --skip-new 启动,则 delay_key_write 的值将被设置为 OFF。If you start mysqld with --skip-new, delay_key_write is set to OFF.

    Warning

    如果你通过 --external-locking 启用外部锁定,对于使用延迟键写的表,将不会有防止索引损坏的保护。If you enable external locking with --external-locking, there is no protection against index corruption for tables that use delayed key writes.

  • delayed_insert_limit

    命令行格式Command-Line Format --delayed-insert-limit=#
    已弃用Deprecated 是Yes
    系统变量System Variable delayed_insert_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 100
    最小值Minimum Value 1
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    该系统变量已被弃用(因为不支持DELAYED 插入),您应该预期它将在未来的版本中被移除。This system variable is deprecated (because DELAYED inserts are not supported), and you should expect it to be removed in a future release.

  • delayed_insert_timeout

    命令行格式Command-Line Format --delayed-insert-timeout=#
    已弃用Deprecated 是Yes
    系统变量System Variable delayed_insert_timeout
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 300
    最小值Minimum Value 1
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    该系统变量已被弃用(因为不支持DELAYED 插入),您应该预期它将在未来的版本中被移除。This system variable is deprecated (because DELAYED inserts are not supported), and you should expect it to be removed in a future release.

  • delayed_queue_size

    命令行格式Command-Line Format --delayed-queue-size=#
    已弃用Deprecated 是Yes
    系统变量System Variable delayed_queue_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1000
    最小值Minimum Value 1
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    该系统变量已被弃用(因为不支持DELAYED 插入),您应该预期它将在未来的版本中被移除。This system variable is deprecated (because DELAYED inserts are not supported), and you should expect it to be removed in a future release.

  • disabled_storage_engines

    命令行格式Command-Line Format --disabled-storage-engines=engine[,engine]...
    系统变量System Variable disabled_storage_engines
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value empty stringempty string

    该变量指示哪些存储引擎不能用于创建表或表空间。例如,要防止创建新的 MyISAM 或 FEDERATED 表,可以在服务器选项文件中使用以下几行启动服务器:This variable indicates which storage engines cannot be used to create tables or tablespaces. For example, to prevent new MyISAM or FEDERATED tables from being created, start the server with these lines in the server option file:

    [mysqld]
    disabled_storage_engines="MyISAM,FEDERATED"
    

    默认情况下,disabled_storage_engines为空(未禁用引擎),但可设置为一个或多个引擎的逗号分隔列表(不区分大小写)。值中命名的任何引擎都不能用于创建具有 CREATE TABLE 或 CREATE TABLESPACE,且不能与 ALTER TABLE ... ENGINE 或 ALTER TABLESPACE ... ENGINE 用于更改现有表或表空间的存储引擎。尝试更改时会出现 ER_DISABLED_STORAGE_ENGINE 错误。By default, disabled_storage_engines is empty (no engines disabled), but it can be set to a comma-separated list of one or more engines (not case-sensitive). Any engine named in the value cannot be used to create tables or tablespaces with CREATE TABLE or CREATE TABLESPACE, and cannot be used with ALTER TABLE ... ENGINE or ALTER TABLESPACE ... ENGINE to change the storage engine of existing tables or tablespaces. Attempts to do so result in an ER_DISABLED_STORAGE_ENGINE error.

    disabled_storage_engines不限制现有表的其他 DDL 语句,例如CREATE INDEX, TRUNCATE TABLE, ANALYZE TABLE, DROP TABLE,或DROP TABLESPACE。这允许平稳过渡,使使用禁用引擎的现有表或表空间可以通过例如ALTER TABLE ... ENGINE permitted_engine.disabled_storage_engines does not restrict other DDL statements for existing tables, such as CREATE INDEX, TRUNCATE TABLE, ANALYZE TABLE, DROP TABLE, or DROP TABLESPACE. This permits a smooth transition so that existing tables or tablespaces that use a disabled engine can be migrated to a permitted engine by means such as ALTER TABLE ... ENGINE permitted_engine.

    允许将 default_storage_engine 或 default_tmp_storage_engine 系统变量设置为已禁用的存储引擎。这可能导致应用程序行为异常或失败,尽管在开发环境中这可能是一个有用的技术,用于识别使用已禁用引擎的应用程序,以便对其进行修改。It is permitted to set the default_storage_engine or default_tmp_storage_engine system variable to a storage engine that is disabled. This could cause applications to behave erratically or fail, although that might be a useful technique in a development environment for identifying applications that use disabled engines, so that they can be modified.

    disabled_storage_engines 如果服务器是使用以下任何选项启动的,将被禁用且无效:--initialize、--initialize-insecure、--skip-grant-tables。disabled_storage_engines is disabled and has no effect if the server is started with any of these options: --initialize, --initialize-insecure, --skip-grant-tables.

  • disconnect_on_expired_password

    命令行格式Command-Line Format --disconnect-on-expired-password[={OFF|ON}]--disconnect-on-expired-password[={OFF|ON}]
    系统变量System Variable disconnect_on_expired_passworddisconnect_on_expired_password
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    此变量控制服务器如何处理密码已过期的客户端:This variable controls how the server handles clients with expired passwords:

    有关客户端和服务器设置在处理过期密码方面的交互的更多信息,请参见 第 8.2.16 节,“服务器处理过期密码”。For more information about the interaction of client and server settings relating to expired-password handling, see Section 8.2.16, “Server Handling of Expired Passwords”.

  • div_precision_increment

    命令行格式Command-Line Format --div-precision-increment=#
    系统变量System Variable div_precision_increment
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 4
    最小值Minimum Value 0
    最大值Maximum Value 30

    此变量表示使用 / 运算符进行除法运算时,结果的小数位数增加的位数。默认值为 4。最小值和最大值分别为 0 和 30。以下示例说明增加默认值的效果。This variable indicates the number of digits by which to increase the scale of the result of division operations performed with the / operator. The default value is 4. The minimum and maximum values are 0 and 30, respectively. The following example illustrates the effect of increasing the default value.

    mysql> SELECT 1/7;
    +--------+
    | 1/7    |
    +--------+
    | 0.1429 |
    +--------+
    mysql> SET div_precision_increment = 12;
    mysql> SELECT 1/7;
    +----------------+
    | 1/7            |
    +----------------+
    | 0.142857142857 |
    +----------------+
    
  • dragnet.log_error_filter_rules

    命令行格式Command-Line Format --dragnet.log-error-filter-rules=value
    系统变量System Variable dragnet.log_error_filter_rules
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value IF prio>=INFORMATION THEN drop. IF EXISTS source_line THEN unset source_line.IF prio>=INFORMATION THEN drop. IF EXISTS source_line THEN unset source_line.

    控制 log_filter_dragnet 错误日志过滤组件操作的过滤规则。如果未安装 log_filter_dragnet,则 dragnet.log_error_filter_rules 无法使用。如果安装了 log_filter_dragnet 但未启用,对 dragnet.log_error_filter_rules 的更改将不会生效。The filter rules that control operation of the log_filter_dragnet error log filter component. If log_filter_dragnet is not installed, dragnet.log_error_filter_rules is unavailable. If log_filter_dragnet is installed but not enabled, changes to dragnet.log_error_filter_rules have no effect.

    默认值的效果类似于使用设置为 log_error_verbosity=2 的 log_sink_internal 过滤器执行的过滤操作。The effect of the default value is similar to the filtering performed by the log_sink_internal filter with a setting of log_error_verbosity=2.

    可以查询 dragnet.Status 状态变量,以确定最近一次对 dragnet.log_error_filter_rules 的赋值结果。dragnet.Status status variable can be consulted to determine the result of the most recent assignment to dragnet.log_error_filter_rules.

  • enterprise_encryption.maximum_rsa_key_size

    命令行格式Command-Line Format --enterprise-encryption.maximum-rsa-key-size=#
    系统变量System Variable enterprise_encryption.maximum_rsa_key_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 4096
    最小值Minimum Value 2048
    最大值Maximum Value 16384

    此变量限制 MySQL 企业加密生成的 RSA 密钥的最大大小。仅当安装了 MySQL 企业加密组件 component_enterprise_encryption 时,该变量才可用。This variable limits the maximum size of RSA keys generated by MySQL Enterprise Encryption. The variable is available only if the MySQL Enterprise Encryption component component_enterprise_encryption is installed.

    最低设置为 2048 位,这是当前最佳实践可接受的最小 RSA 密钥长度。默认设置为 4096 位。最高设置为 16384 位。生成更长的密钥可能会消耗大量 CPU 资源,因此您可以使用此设置将密钥限制为在满足安全需求的同时平衡资源使用的长度。有关更多信息,请参见第 8.6.2 节,“配置 MySQL 企业加密”。The lowest setting is 2048 bits, which is the minimum RSA key length that is acceptable by current best practice. The default setting is 4096 bits. The highest setting is 16384 bits. Generating longer keys can consume significant CPU resources, so you can use this setting to limit keys to a length that provides adequate security for your requirements while balancing this with resource usage. See Section 8.6.2, “Configuring MySQL Enterprise Encryption” for more information.

  • enterprise_encryption.rsa_support_legacy_padding

    命令行格式Command-Line Format --enterprise-encryption.rsa_support_legacy_padding[={OFF|ON}]
    系统变量System Variable enterprise_encryption.rsa_support_legacy_padding
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此变量控制 MySQL 企业加密生成的使用旧 openssl_udf 共享库函数的加密数据和签名是否可以被 MySQL 企业加密组件 (component_enterprise_encryption) 解密或验证。此变量仅在安装了 MySQL 企业加密组件时可用。This variable controls whether encrypted data and signatures that MySQL Enterprise Encryption produced using the old openssl_udf shared library functions can be decrypted or verified by the MySQL Enterprise Encryption component (component_enterprise_encryption). The variable is available only if the MySQL Enterprise Encryption component is installed.

    为了使组件函数支持对旧的 openssl_udf 共享库函数生成的内容进行解密和验证,您必须将系统变量 padding 设置为 ON。当设置为 ON 时,如果组件函数在假设内容使用 RSAES-OAEP 或 RSASSA-PSS 方案(由组件使用)时无法解密或验证,它们会再次尝试假设内容使用 RSAES-PKCS1-v1_5 或 RSASSA-PKCS1-v1_5 方案(由 openssl_udf 共享库函数使用)。当设置为 OFF 时,如果组件函数无法使用其正常方案解密或验证内容,它们会返回空输出。有关更多信息,请参见 第 8.6.2 节,“配置 MySQL 企业加密”。For the component functions to support decryption and verification for content produced by the old openssl_udf shared library functions, you must set the system variable padding to ON. When ON is set, if the component functions cannot decrypt or verify content when assuming it has the RSAES-OAEP or RSASSA-PSS scheme (as used by the component), they make another attempt assuming it has the RSAES-PKCS1-v1_5 or RSASSA-PKCS1-v1_5 scheme (as used by the openssl_udf shared library functions). When OFF is set, if the component functions cannot decrypt or verify content using their normal schemes, they return null output. See Section 8.6.2, “Configuring MySQL Enterprise Encryption” for more information.

  • end_markers_in_json

    命令行格式Command-Line Format --end-markers-in-json[={OFF|ON}]
    系统变量System Variable end_markers_in_json
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    优化器 JSON 输出是否应添加结束标记。请参阅第 10.15.9 节,“end_markers_in_json 系统变量”。Whether optimizer JSON output should add end markers. See Section 10.15.9, “The end_markers_in_json System Variable”.

  • eq_range_index_dive_limit

    命令行格式Command-Line Format --eq-range-index-dive-limit=#
    系统变量System Variable eq_range_index_dive_limit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 200
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    该变量指示在优化器估算符合条件的行数时,对于相等比较条件中的相等范围数量,优化器应从使用索引深入查找改为使用索引统计信息。它适用于评估具有以下等效形式的表达式,其中优化器使用非唯一索引查找col_name值:This variable indicates the number of equality ranges in an equality comparison condition when the optimizer should switch from using index dives to index statistics in estimating the number of qualifying rows. It applies to evaluation of expressions that have either of these equivalent forms, where the optimizer uses a nonunique index to look up col_name values:

    col_name IN(val1, ..., valN)
    col_name = val1 OR ... OR col_name = valN
    

    在这两种情况下,表达式都包含N个等值范围。优化器可以使用索引深入或索引统计来进行行估计。如果eq_range_index_dive_limit大于 0,当存在eq_range_index_dive_limit个或更多等值范围时,优化器会使用现有索引统计而不是索引深入。因此,要允许最多N个等值范围使用索引深入,请将eq_range_index_dive_limit设置为N + 1。若要禁用索引统计并始终使用索引深入,而不管N的值是多少,将eq_range_index_dive_limit设置为 0。In both cases, the expression contains N equality ranges. The optimizer can make row estimates using index dives or index statistics. If eq_range_index_dive_limit is greater than 0, the optimizer uses existing index statistics instead of index dives if there are eq_range_index_dive_limit or more equality ranges. Thus, to permit use of index dives for up to N equality ranges, set eq_range_index_dive_limit to N + 1. To disable use of index statistics and always use index dives regardless of N, set eq_range_index_dive_limit to 0.

    欲了解更多信息,请参见 多值比较的相等范围优化。For more information, see Equality Range Optimization of Many-Valued Comparisons.

    要更新表索引统计以获得最佳估计,请使用 ANALYZE TABLE。To update table index statistics for best estimates, use ANALYZE TABLE.

  • error_count error_count

    上一个生成消息的语句导致的错误数量。此变量为只读。请参见 第 15.7.7.18 节,“SHOW ERRORS 语句”。The number of errors that resulted from the last statement that generated messages. This variable is read only. See Section 15.7.7.18, “SHOW ERRORS Statement”.

  • event_scheduler event_scheduler

    命令行格式Command-Line Format --event-scheduler[=value]--event-scheduler[=value]
    系统变量System Variable event_schedulerevent_scheduler
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value ONON
    有效值Valid Values

    ONON

    OFFOFF

    DISABLEDDISABLED

    该变量用于启用或禁用事件调度器,并启动或停止事件调度器。可能的状态值为ON、OFF和DISABLED。将事件调度器设置为OFF不等同于禁用事件调度器,禁用事件调度器需要将状态设置为DISABLED。关于此变量及其对事件调度器操作的影响,可以在第 27.4.2 节,“事件调度器配置”中找到更详细的讨论This variable enables or disables, and starts or stops, the Event Scheduler. The possible status values are ON, OFF, and DISABLED. Turning the Event Scheduler OFF is not the same as disabling the Event Scheduler, which requires setting the status to DISABLED. This variable and its effects on the Event Scheduler's operation are discussed in greater detail in Section 27.4.2, “Event Scheduler Configuration”

  • explain_format explain_format

    命令行格式Command-Line Format --explain-format=format--explain-format=format
    系统变量System Variable explain_formatexplain_format
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value TRADITIONALTRADITIONAL
    有效值Valid Values

    TRADITIONALTRADITIONAL

    JSON

    TREETREE

    该变量决定在显示查询执行计划时,如果没有 FORMAT 选项,EXPLAIN 使用的默认输出格式。可能的值及其效果列在此处:This variable determines the default output format used by EXPLAIN in the absence of a FORMAT option when displaying a query execution plan. Possible values and their effects are listed here:

    • TRADITIONAL:使用 MySQL 的传统表格输出,就好像在 EXPLAIN 语句中指定了 FORMAT=TRADITIONAL。这是该变量的默认值。DEFAULT 也被支持作为 TRADITIONAL 的同义词,效果完全相同。TRADITIONAL: Use MySQL's traditional table-based output, as if FORMAT=TRADITIONAL had been specified as part of the EXPLAIN statement. This is the variable's default value. DEFAULT is also supported as a synonym for TRADITIONAL, and has exactly the same effect.

      Note

      DEFAULT 不能用作 EXPLAIN 语句的 FORMAT 选项的一部分。DEFAULT cannot be used as part of an EXPLAIN statement's FORMAT option.

    • JSON:使用 JSON 输出格式,就好像指定了 FORMAT=JSON。JSON: Use the JSON output format, as if FORMAT=JSON had been specified.

    • TREE:使用基于树的输出格式,就好像指定了 FORMAT=TREE。TREE: Use the tree-based output format, as if FORMAT=TREE had been specified.

    此变量的设置还会影响 EXPLAIN ANALYZE。因此,DEFAULT 和 TRADITIONAL 被解释为 TREE。如果 explain_format 的值为 JSON,且执行没有 FORMAT 选项的 EXPLAIN ANALYZE 语句,则该语句会报错(ER_NOT_SUPPORTED_YET)。The setting for this variable also affects EXPLAIN ANALYZE. For this purpose, DEFAULT and TRADITIONAL are interpeted as TREE. If the value of explain_format is JSON and an EXPLAIN ANALYZE statement having no FORMAT option is issued, the statement raises an error (ER_NOT_SUPPORTED_YET).

    在 EXPLAIN 或 EXPLAIN ANALYZE 中使用格式说明符会覆盖 explain_format 的任何设置。Using a format specifier with EXPLAIN or EXPLAIN ANALYZE overrides any setting for explain_format.

    explain_format 系统变量在使用此语句显示表列信息时,对 EXPLAIN 输出没有影响。The explain_format system variable has no effect on EXPLAIN output when this statement is used to display information about table columns.

    设置会话级别的 explain_format 无需特殊权限;在全局级别设置它需要 SYSTEM_VARIABLES_ADMIN(或已弃用的 SUPER 权限)。请参见 第 7.1.9.1 节,“系统变量权限”。Setting the session value of explain_format requires no special privileges; setting it on the global level requires SYSTEM_VARIABLES_ADMIN (or the deprecated SUPER privilege). See Section 7.1.9.1, “System Variable Privileges”.

    有关详细信息和示例,请参阅获取执行计划信息。For more information and examples, see Obtaining Execution Plan Information.

  • explain_json_format_version

    命令行格式Command-Line Format --explain-json-format-version=#
    系统变量System Variable explain_json_format_version
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1
    最小值Minimum Value 1
    最大值Maximum Value 2

    决定 EXPLAIN FORMAT=JSON 语句使用的 JSON 输出格式的版本。将此变量设置为 1 会导致服务器使用版本 1,这是旧版本 MySQL 中此类语句输出所使用的线性格式;在 MySQL 8.4 中,这是默认值。将 explain_json_format_version 设置为 2 会使用版本 2 格式;这种 JSON 输出格式基于访问路径,旨在提供与未来版本 MySQL 优化器的更好兼容性。Determines the version of the JSON output format used by EXPLAIN FORMAT=JSON statements. Setting this variable to 1 causes the server to use Version 1, which is the linear format used for output from such statements in older versions of MySQL; this is the default in MySQL 8.4. Setting explain_json_format_version to 2 causes the Version 2 format to be used; this JSON output format is based on access paths, and is intended to provide better compatibility with future versions of the MySQL Optimizer.

    有关用法示例,请参见 获取执行计划信息。For an example of use, see Obtaining Execution Plan Information.

  • explicit_defaults_for_timestamp

    命令行格式Command-Line Format --explicit-defaults-for-timestamp[={OFF|ON}]
    已弃用Deprecated 是Yes
    系统变量System Variable explicit_defaults_for_timestamp
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    此系统变量决定服务器是否启用某些非标准行为,用于 TIMESTAMP 列的默认值和 NULL 值处理。默认情况下,explicit_defaults_for_timestamp 是启用的,这会禁用非标准行为。禁用 explicit_defaults_for_timestamp 会产生警告。This system variable determines whether the server enables certain nonstandard behaviors for default values and NULL-value handling in TIMESTAMP columns. By default, explicit_defaults_for_timestamp is enabled, which disables the nonstandard behaviors. Disabling explicit_defaults_for_timestamp results in a warning.

    如果explicit_defaults_for_timestamp 被禁用,服务器将启用非标准行为,并按以下方式处理TIMESTAMP 列:If explicit_defaults_for_timestamp is disabled, the server enables the nonstandard behaviors and handles TIMESTAMP columns as follows:

    • TIMESTAMP 列如果没有显式声明 NULL 属性,则会自动声明为 NOT NULL 属性。向此类列赋值 NULL 是允许的,并会将该列设置为当前时间戳。例外:尝试将 NULL 插入声明为 TIMESTAMP NOT NULL 的生成列时,会报错。TIMESTAMP columns not explicitly declared with the NULL attribute are automatically declared with the NOT NULL attribute. Assigning such a column a value of NULL is permitted and sets the column to the current timestamp. Exception: Attempting to insert NULL into a generated column declared as TIMESTAMP NOT NULL is rejected with an error.

    • 表中的第一个 TIMESTAMP 列,如果没有显式声明 NULL 属性,或者显式声明 DEFAULT 或 ON UPDATE 属性,将自动声明为 DEFAULT CURRENT_TIMESTAMP 和 ON UPDATE CURRENT_TIMESTAMP 属性。The first TIMESTAMP column in a table, if not explicitly declared with the NULL attribute or an explicit DEFAULT or ON UPDATE attribute, is automatically declared with the DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP attributes.

    • TIMESTAMP 列在第一个之后,如果没有显式声明 NULL 属性或显式的 DEFAULT 属性,则会自动声明为 DEFAULT '0000-00-00 00:00:00'(即 “零” 时间戳)。对于插入的行,如果没有为该列指定显式值,则该列将被分配 '0000-00-00 00:00:00',且不会发生警告。TIMESTAMP columns following the first one, if not explicitly declared with the NULL attribute or an explicit DEFAULT attribute, are automatically declared as DEFAULT '0000-00-00 00:00:00' (the “zero” timestamp). For inserted rows that specify no explicit value for such a column, the column is assigned '0000-00-00 00:00:00' and no warning occurs.

      根据是否启用了严格 SQL 模式或 NO_ZERO_DATE SQL 模式,默认值 '0000-00-00 00:00:00' 可能无效。请注意,TRADITIONAL SQL 模式包括严格模式和 NO_ZERO_DATE。参见 第 7.1.11 节,“服务器 SQL 模式”。Depending on whether strict SQL mode or the NO_ZERO_DATE SQL mode is enabled, a default value of '0000-00-00 00:00:00' may be invalid. Be aware that the TRADITIONAL SQL mode includes strict mode and NO_ZERO_DATE. See Section 7.1.11, “Server SQL Modes”.

    刚刚描述的非标准行为已被弃用;预计它们将在未来的 MySQL 版本中被移除。The nonstandard behaviors just described are deprecated; expect them to be removed in a future MySQL release.

    如果启用了 explicit_defaults_for_timestamp,服务器将禁用非标准行为,并且 TIMESTAMP 列的处理方式如下:If explicit_defaults_for_timestamp is enabled, the server disables the nonstandard behaviors and handles TIMESTAMP columns as follows:

    • 不可能将 TIMESTAMP 列赋值为 NULL 来设置为当前时间戳。要分配当前时间戳,请将该列设置为 CURRENT_TIMESTAMP 或其同义词,例如 NOW()。It is not possible to assign a TIMESTAMP column a value of NULL to set it to the current timestamp. To assign the current timestamp, set the column to CURRENT_TIMESTAMP or a synonym such as NOW().

    • TIMESTAMP 列如果没有明确声明 NOT NULL 属性,将自动声明为 NULL 属性,并允许 NULL 值。给这样的列赋值为 NULL 会将其设置为 NULL,而不是当前时间戳。TIMESTAMP columns not explicitly declared with the NOT NULL attribute are automatically declared with the NULL attribute and permit NULL values. Assigning such a column a value of NULL sets it to NULL, not the current timestamp.

    • TIMESTAMP 列如果声明了 NOT NULL 属性,则不允许 NULL 值。对于插入操作,如果指定 NULL 给此类列,在启用严格 SQL 模式下的单行插入会导致错误;在禁用严格 SQL 模式的多行插入中,则插入 '0000-00-00 00:00:00'。无论如何,将该列赋值为 NULL 都不会将其设置为当前时间戳。TIMESTAMP columns declared with the NOT NULL attribute do not permit NULL values. For inserts that specify NULL for such a column, the result is either an error for a single-row insert if strict SQL mode is enabled, or '0000-00-00 00:00:00' is inserted for multiple-row inserts with strict SQL mode disabled. In no case does assigning the column a value of NULL set it to the current timestamp.

    • TIMESTAMP 列如果显式声明了 NOT NULL 属性且未显式声明 DEFAULT 属性,则被视为没有默认值。对于插入的新行,如果未为此类列指定显式值,结果取决于 SQL 模式。如果启用了严格 SQL 模式,将发生错误。如果未启用严格 SQL 模式,该列将使用隐式默认值 '0000-00-00 00:00:00' 并会生成警告。这与 MySQL 对其他时间类型(如 DATETIME)的处理方式类似。TIMESTAMP columns explicitly declared with the NOT NULL attribute and without an explicit DEFAULT attribute are treated as having no default value. For inserted rows that specify no explicit value for such a column, the result depends on the SQL mode. If strict SQL mode is enabled, an error occurs. If strict SQL mode is not enabled, the column is declared with the implicit default of '0000-00-00 00:00:00' and a warning occurs. This is similar to how MySQL treats other temporal types such as DATETIME.

    • 没有 TIMESTAMP 列会自动声明为 DEFAULT CURRENT_TIMESTAMP 或 ON UPDATE CURRENT_TIMESTAMP 属性。这些属性必须明确指定。No TIMESTAMP column is automatically declared with the DEFAULT CURRENT_TIMESTAMP or ON UPDATE CURRENT_TIMESTAMP attributes. Those attributes must be explicitly specified.

    • 表中的第一个 TIMESTAMP 列与后续的 TIMESTAMP 列没有区别。The first TIMESTAMP column in a table is not handled differently from TIMESTAMP columns following the first one.

    如果在服务器启动时禁用了 explicit_defaults_for_timestamp,错误日志中会出现此警告:If explicit_defaults_for_timestamp is disabled at server startup, this warning appears in the error log:

    [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
    Please use --explicit_defaults_for_timestamp server option (see
    documentation for more details).
    

    如警告所示,要禁用已弃用的非标准行为,请在服务器启动时启用 explicit_defaults_for_timestamp 系统变量。As indicated by the warning, to disable the deprecated nonstandard behaviors, enable the explicit_defaults_for_timestamp system variable at server startup.

    Note

    explicit_defaults_for_timestamp 本身也已被弃用,因为它的唯一目的是允许控制将在未来 MySQL 版本中移除的已弃用 TIMESTAMP 行为。当这些行为被移除时,预计 explicit_defaults_for_timestamp 也将被移除。explicit_defaults_for_timestamp is itself deprecated because its only purpose is to permit control over deprecated TIMESTAMP behaviors that are to be removed in a future MySQL release. When removal of those behaviors occurs, expect explicit_defaults_for_timestamp to be removed as well.

    有关更多信息,请参见 第 13.2.5 节,“TIMESTAMP 与 DATETIME 的自动初始化和更新”。For additional information, see Section 13.2.5, “Automatic Initialization and Updating for TIMESTAMP and DATETIME”.

  • external_user

    系统变量System Variable external_user
    范围Scope 会议Session
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    在身份验证过程中使用的外部用户名,由用于身份验证客户端的插件设置。对于原生(内置)MySQL 身份验证,或者如果插件未设置此值,则该变量为 NULL。请参见 第 8.2.19 节,“代理用户”。The external user name used during the authentication process, as set by the plugin used to authenticate the client. With native (built-in) MySQL authentication, or if the plugin does not set the value, this variable is NULL. See Section 8.2.19, “Proxy Users”.

  • flush

    命令行格式Command-Line Format --flush[={OFF|ON}]
    系统变量System Variable flush
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    仅适用于 MyISAM。Applies to MyISAM, only.

    如果 ON,服务器将在每条 SQL 语句之后将所有更改刷新(同步)到磁盘。通常,MySQL 仅在每条 SQL 语句之后将所有更改写入磁盘,并让操作系统处理磁盘的同步。参见 B.3.3.3 节,“如果 MySQL 不断崩溃该怎么办”。如果你使用 mysqld 并带上 --flush 选项启动,则此变量被设置为 ON。If ON, the server flushes (synchronizes) all changes to disk after each SQL statement. Normally, MySQL does a write of all changes to disk only after each SQL statement and lets the operating system handle the synchronizing to disk. See Section B.3.3.3, “What to Do If MySQL Keeps Crashing”. This variable is set to ON if you start mysqld with the --flush option.

    Note

    如果flush已启用,flush_time的值无关紧要,对flush_time的更改不会影响刷新行为。If flush is enabled, the value of flush_time does not matter and changes to flush_time have no effect on flush behavior.

  • flush_time

    命令行格式Command-Line Format --flush-time=#
    系统变量System Variable flush_time
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    如果将此设置为非零值,则每隔 flush_time 秒关闭所有表,以释放资源并将未刷新数据同步到磁盘。此选项最好仅在资源有限的系统上使用。If this is set to a nonzero value, all tables are closed every flush_time seconds to free up resources and synchronize unflushed data to disk. This option is best used only on systems with minimal resources.

    Note

    如果flush已启用,flush_time的值无关紧要,对flush_time的更改不会影响刷新行为。If flush is enabled, the value of flush_time does not matter and changes to flush_time have no effect on flush behavior.

  • foreign_key_checks

    系统变量System Variable foreign_key_checks
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果设置为 1(默认值),将检查外键约束。如果设置为 0,则忽略外键约束,但有几个例外。当重新创建已删除的表时,如果表定义不符合引用该表的外键约束,则会返回错误。同样,如果外键定义格式不正确,ALTER TABLE 操作会返回错误。有关更多信息,请参阅 第 15.1.20.5 节,“外键约束”。If set to 1 (the default), foreign key constraints are checked. If set to 0, foreign key constraints are ignored, with a couple of exceptions. When re-creating a table that was dropped, an error is returned if the table definition does not conform to the foreign key constraints referencing the table. Likewise, an ALTER TABLE operation returns an error if a foreign key definition is incorrectly formed. For more information, see Section 15.1.20.5, “FOREIGN KEY Constraints”.

    设置此变量对NDB表的效果与对InnoDB表的效果相同。通常在正常操作期间保持此设置启用,以强制参照完整性。禁用外键检查对以不同于父子关系要求的顺序重新加载InnoDB表可能很有用。请参阅第 15.1.20.5 节,“外键约束”。Setting this variable has the same effect on NDB tables as it does for InnoDB tables. Typically you leave this setting enabled during normal operation, to enforce referential integrity. Disabling foreign key checking can be useful for reloading InnoDB tables in an order different from that required by their parent/child relationships. See Section 15.1.20.5, “FOREIGN KEY Constraints”.

    将 foreign_key_checks 设置为 0 也会影响数据定义语句:DROP SCHEMA 即使模式中包含被模式外的表引用的外键表,也会删除该模式,而 DROP TABLE 会删除被其他表引用外键的表。Setting foreign_key_checks to 0 also affects data definition statements: DROP SCHEMA drops a schema even if it contains tables that have foreign keys that are referred to by tables outside the schema, and DROP TABLE drops tables that have foreign keys that are referred to by other tables.

    Note

    将 foreign_key_checks 设置为 1 不会触发对现有表数据的扫描。因此,在 foreign_key_checks = 0 时添加到表的行不会进行一致性验证。Setting foreign_key_checks to 1 does not trigger a scan of the existing table data. Therefore, rows added to the table while foreign_key_checks = 0 are not verified for consistency.

    不允许删除被外键约束使用的索引,即使设置了 foreign_key_checks=0。必须先删除外键约束,然后才能删除索引。Dropping an index required by a foreign key constraint is not permitted, even with foreign_key_checks=0. The foreign key constraint must be removed before dropping the index.

  • ft_boolean_syntax

    命令行格式Command-Line Format --ft-boolean-syntax=name
    系统变量System Variable ft_boolean_syntax
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value + -><()~*:""&|

    使用 IN BOOLEAN MODE 进行布尔全文搜索所支持的运算符列表。请参阅 第 14.9.2 节,“布尔全文搜索”。The list of operators supported by boolean full-text searches performed using IN BOOLEAN MODE. See Section 14.9.2, “Boolean Full-Text Searches”.

    默认变量值为 '+ -><()~*:""&|'。更改该值的规则如下:The default variable value is '+ -><()~*:""&|'. The rules for changing the value are as follows:

    • 操作符函数由字符串中的位置决定。Operator function is determined by position within the string.

    • 替换值必须是 14 个字符。The replacement value must be 14 characters.

    • 每个字符必须是 ASCII 非字母数字字符。Each character must be an ASCII nonalphanumeric character.

    • 第一个或第二个字符必须为空格。Either the first or second character must be a space.

    • 不允许重复,除了位于第 11 和第 12 位置引用操作符的短语。这两个字符不必相同,但它们是唯一可以重复的两个字符。No duplicates are permitted except the phrase quoting operators in positions 11 and 12. These two characters are not required to be the same, but they are the only two that may be.

    • 位置 10、13 和 14(默认设置为 :、& 和 |)保留用于将来的扩展。Positions 10, 13, and 14 (which by default are set to :, &, and |) are reserved for future extensions.

  • ft_max_word_len

    命令行格式Command-Line Format --ft-max-word-len=#
    系统变量System Variable ft_max_word_len
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 84
    最小值Minimum Value 10
    最大值Maximum Value 84

    要包含在 MyISAM FULLTEXT 索引中的最大单词长度。The maximum length of the word to be included in a MyISAM FULLTEXT index.

    Note

    更改此变量后,必须重建 MyISAM 表上的 FULLTEXT 索引。使用 REPAIR TABLE tbl_name QUICK。FULLTEXT indexes on MyISAM tables must be rebuilt after changing this variable. Use REPAIR TABLE tbl_name QUICK.

  • ft_min_word_len

    命令行格式Command-Line Format --ft-min-word-len=#
    系统变量System Variable ft_min_word_len
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 4
    最小值Minimum Value 1
    最大值Maximum Value 82

    要包含在 MyISAM FULLTEXT 索引中的单词的最小长度。The minimum length of the word to be included in a MyISAM FULLTEXT index.

    Note

    更改此变量后,必须重建 MyISAM 表上的 FULLTEXT 索引。使用 REPAIR TABLE tbl_name QUICK。FULLTEXT indexes on MyISAM tables must be rebuilt after changing this variable. Use REPAIR TABLE tbl_name QUICK.

  • ft_query_expansion_limit

    命令行格式Command-Line Format --ft-query-expansion-limit=#
    系统变量System Variable ft_query_expansion_limit
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 20
    最小值Minimum Value 0
    最大值Maximum Value 1000

    使用 WITH QUERY EXPANSION 执行全文搜索时要使用的最高匹配数。The number of top matches to use for full-text searches performed using WITH QUERY EXPANSION.

  • ft_stopword_file

    命令行格式Command-Line Format --ft-stopword-file=file_name--ft-stopword-file=file_name
    系统变量System Variable ft_stopword_file
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name

    用于读取 MyISAM 表全文搜索停用词列表的文件。除非指定绝对路径以使用不同的目录,否则服务器会在数据目录中查找该文件。文件中的所有单词都会被使用;注释 不 会被处理。默认情况下,使用内置的停用词列表(如 storage/myisam/ft_static.c 文件中定义的)。将此变量设置为空字符串 ('') 可禁用停用词过滤。另请参见 第 14.9.4 节,“全文停用词”。The file from which to read the list of stopwords for full-text searches on MyISAM tables. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. All the words from the file are used; comments are not honored. By default, a built-in list of stopwords is used (as defined in the storage/myisam/ft_static.c file). Setting this variable to the empty string ('') disables stopword filtering. See also Section 14.9.4, “Full-Text Stopwords”.

    Note

    FULLTEXT 索引在 MyISAM 表上更改此变量或停止词文件内容后必须重建。使用 REPAIR TABLE tbl_name QUICK。FULLTEXT indexes on MyISAM tables must be rebuilt after changing this variable or the contents of the stopword file. Use REPAIR TABLE tbl_name QUICK.

  • general_log

    命令行格式Command-Line Format --general-log[={OFF|ON}]--general-log[={OFF|ON}]
    系统变量System Variable general_log
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    是否启用通用查询日志。该值可以为 0(或 OFF)以禁用日志,或者为 1(或 ON)以启用日志。日志输出的目标由 log_output 系统变量控制;如果该值为 NONE,即使日志被启用,也不会写入任何日志条目。Whether the general query log is enabled. The value can be 0 (or OFF) to disable the log or 1 (or ON) to enable the log. The destination for log output is controlled by the log_output system variable; if that value is NONE, no log entries are written even if the log is enabled.

  • general_log_file

    命令行格式Command-Line Format --general-log-file=file_name--general-log-file=file_name
    系统变量System Variable general_log_file
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value host_name.log

    通用查询日志文件的名称。默认值是 host_name.log,但是可以使用 --general_log_file 选项更改初始值。The name of the general query log file. The default value is host_name.log, but the initial value can be changed with the --general_log_file option.

  • generated_random_password_length

    命令行格式Command-Line Format --generated-random-password-length=#
    系统变量System Variable generated_random_password_length
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 20
    最小值Minimum Value 5
    最大值Maximum Value 255

    在使用 CREATE USER、ALTER USER 和 SET PASSWORD 语句生成随机密码时允许的最大字符数。有关更多信息,请参见 随机密码生成。The maximum number of characters permitted in random passwords generated for CREATE USER, ALTER USER, and SET PASSWORD statements. For more information, see Random Password Generation.

  • global_connection_memory_limit

    命令行格式Command-Line Format --global-connection-memory-limit=#
    系统变量System Variable global_connection_memory_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 18446744073709551615
    最小值Minimum Value 16777216
    最大值Maximum Value 18446744073709551615
    单位Unit 字节bytes

    设置所有用户连接可以使用的总内存量;也就是说,Global_connection_memory 不应超过此数量。每当超过此数量时,所有来自普通用户的查询(包括当前正在运行的查询)都会被拒绝,并返回 ER_GLOBAL_CONN_LIMIT。Set the total amount of memory that can be used by all user connections; that is, Global_connection_memory should not exceed this amount. Any time that it does, all queries (including any currently running) from regular users are rejected with ER_GLOBAL_CONN_LIMIT.

    系统用户(例如 MySQL 根用户)使用的内存包含在此总量中,但不计入断开连接限制;此类用户从不会因内存使用而被断开连接。Memory used by the system users such as the MySQL root user is included in this total, but is not counted towards the disconnection limit; such users are never disconnected due to memory usage.

    InnoDB缓冲池使用的内存不计入总量。Memory used by the InnoDB buffer pool is excluded from the total.

    您必须拥有 SYSTEM_VARIABLES_ADMIN 或 SUPER 权限才能设置此变量。You must have the SYSTEM_VARIABLES_ADMIN or SUPER privilege to set this variable.

  • global_connection_memory_tracking

    命令行格式Command-Line Format --global-connection-memory-tracking={TRUE|FALSE}
    系统变量System Variable global_connection_memory_tracking
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value FALSE

    确定服务器是否计算 Global_connection_memory。此变量必须显式启用,否则不会执行内存计算,并且 Global_connection_memory 不会被设置。Determines whether the server calculates Global_connection_memory. This variable must be enabled explicitly; otherwise, the memory calculation is not performed, and Global_connection_memory is not set.

    您必须拥有 SYSTEM_VARIABLES_ADMIN 或 SUPER 权限才能设置此变量。You must have the SYSTEM_VARIABLES_ADMIN or SUPER privilege to set this variable.

  • group_concat_max_len

    命令行格式Command-Line Format --group-concat-max-len=#
    系统变量System Variable group_concat_max_len
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 1024
    最小值Minimum Value 4
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    GROUP_CONCAT() 函数允许的最大结果长度(以字节为单位)。默认值为 1024。The maximum permitted result length in bytes for the GROUP_CONCAT() function. The default is 1024.

    Important

    在为 group_concat_max_len 设置值时,请考虑以下内容:When setting the value for group_concat_max_len, consider the following:

    • 估算 GROUP_CONCAT() 输出所需的最大长度,并相应地设置该值。Estimate the maximum length required for GROUP_CONCAT() output and set the value accordingly.

    • 将值设置得过高可能会对性能产生负面影响,并导致内存不足(OOM)错误。Setting the value excessively high can negatively affect performance and lead to out-of-memory (OOM) errors.

    • 在 MySQL HeatWave 中,最大列长度为 4 MB,因此设置高于此值会导致输出被截断。为避免这种情况,请将值设置在 4 MB 以下。In MySQL HeatWave, the maximum column length is 4 MB, so setting a value higher than this causes the output to be truncated. To avoid this, set a value under 4 MB.

  • have_compress

    如果服务器可以使用 zlib 压缩库,则为 YES,如果不能,则为 NO。如果不能,COMPRESS() 和 UNCOMPRESS() 函数不能使用。YES if the zlib compression library is available to the server, NO if not. If not, the COMPRESS() and UNCOMPRESS() functions cannot be used.

  • have_dynamic_loading

    YES 如果 mysqld 支持插件的动态加载,NO 如果不支持。如果值为 NO,则无法使用诸如 --plugin-load 之类的选项在服务器启动时加载插件,或使用 INSTALL PLUGIN 语句在运行时加载插件。YES if mysqld supports dynamic loading of plugins, NO if not. If the value is NO, you cannot use options such as --plugin-load to load plugins at server startup, or the INSTALL PLUGIN statement to load plugins at runtime.

  • have_geometry

    YES 如果服务器支持空间数据类型,NO 如果不支持。YES if the server supports spatial data types, NO if not.

  • have_profiling

    如果存在语句分析功能,则为YES;如果不存在,则为NO。如果存在,profiling系统变量控制此功能是启用还是禁用。请参见第 15.7.7.33 节,“SHOW PROFILES 语句”。YES if statement profiling capability is present, NO if not. If present, the profiling system variable controls whether this capability is enabled or disabled. See Section 15.7.7.33, “SHOW PROFILES Statement”.

    此变量已弃用;您应预期它将在未来的 MySQL 版本中被移除。This variable is deprecated; you should expect it to be removed in a future MySQL release.

  • have_query_cache

    have_query_cache 已弃用,总是具有 NO 的值,并且您应预期它将在未来的 MySQL 版本中被移除。have_query_cache is deprecated, always has a value of NO, and you should expect it to be removed in a future MySQL release.

  • have_rtree_keys

    YES 表示 RTREE 索引可用,NO 表示不可用。(这些用于 MyISAM 表中的空间索引。)YES if RTREE indexes are available, NO if not. (These are used for spatial indexes in MyISAM tables.)

  • have_statement_timeout

    系统变量System Variable have_statement_timeout
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean

    语句执行超时功能是否可用(参见 语句执行时间优化器提示)。如果此功能使用的后台线程无法初始化,则该值可能为 NO。Whether the statement execution timeout feature is available (see Statement Execution Time Optimizer Hints). The value can be NO if the background thread used by this feature could not be initialized.

  • have_symlink

    YES 如果启用了符号链接支持,NO 如果没有。在 Unix 系统上这是支持 DATA DIRECTORY 和 INDEX DIRECTORY 表选项所必需的。如果服务器使用 --skip-symbolic-links 选项启动,则值为 DISABLED。YES if symbolic link support is enabled, NO if not. This is required on Unix for support of the DATA DIRECTORY and INDEX DIRECTORY table options. If the server is started with the --skip-symbolic-links option, the value is DISABLED.

    这个变量在 Windows 上没有意义。This variable has no meaning on Windows.

    Note

    符号链接支持,以及控制它的--symbolic-links选项已被弃用;预计将在未来的 MySQL 版本中删除。此外,该选项默认被禁用。相关的have_symlink系统变量也已被弃用,您应该预计它将在未来的 MySQL 版本中被删除。Symbolic link support, along with the --symbolic-links option that controls it, is deprecated; expect these to be removed in a future version of MySQL. In addition, the option is disabled by default. The related have_symlink system variable also is deprecated and you should expect it to be removed in a future version of MySQL.

  • histogram_generation_max_mem_size

    命令行格式Command-Line Format --histogram-generation-max-mem-size=#
    系统变量System Variable histogram_generation_max_mem_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 20000000
    最小值Minimum Value 1000000
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295
    单位Unit 字节bytes

    生成直方图统计信息可用的最大内存量。参见 第 10.9.6 节,“优化器统计”,以及 第 15.7.3.1 节,“ANALYZE TABLE 语句”。The maximum amount of memory available for generating histogram statistics. See Section 10.9.6, “Optimizer Statistics”, and Section 15.7.3.1, “ANALYZE TABLE Statement”.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • host_cache_size

    命令行格式Command-Line Format --host-cache-size=#
    系统变量System Variable host_cache_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1 (signifies autosizing; do not assign this literal value)
    最小值Minimum Value 0
    最大值Maximum Value 65536

    MySQL 服务器维护了一个内存中的主机缓存,其中包含客户端主机名和 IP 地址信息,用于避免域名系统(DNS)查找;详见 第 7.1.12.3 节,“DNS 查找与主机缓存”。The MySQL server maintains an in-memory host cache that contains client host name and IP address information and is used to avoid Domain Name System (DNS) lookups; see Section 7.1.12.3, “DNS Lookups and the Host Cache”.

    host_cache_size 变量控制主机缓存的大小,以及性能模式(Performance Schema)host_cache 表的大小,该表用于显示缓存内容。设置 host_cache_size 会产生以下效果:The host_cache_size variable controls the size of the host cache, as well as the size of the Performance Schema host_cache table that exposes the cache contents. Setting host_cache_size has these effects:

    • 将大小设置为 0 会禁用主机缓存。禁用缓存后,每次客户端连接时,服务器都会执行 DNS 查找。Setting the size to 0 disables the host cache. With the cache disabled, the server performs a DNS lookup every time a client connects.

    • 在运行时更改大小会导致隐式的主机缓存刷新操作,该操作会清除主机缓存、截断 host_cache 表,并解除任何被阻塞的主机阻塞。Changing the size at runtime causes an implicit host cache flushing operation that clears the host cache, truncates the host_cache table, and unblocks any blocked hosts.

    默认值自动调整为 128,加上 1,对应值为max_connections最高为 500,每超过 500 增加 20 加 1,在max_connections值上,限制在 2000。The default value is autosized to 128, plus 1 for a value of max_connections up to 500, plus 1 for every increment of 20 over 500 in the max_connections value, capped to a limit of 2000.

  • hostname

    系统变量System Variable hostnamehostname
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    服务器在启动时将此变量设置为服务器主机名。最大长度为 255 个字符。The server sets this variable to the server host name at startup. The maximum length is 255 characters.

  • identity

    这个变量是 last_insert_id 变量的同义词。它的存在是为了与其他数据库系统兼容。你可以使用 SELECT @@identity 来读取其值,并使用 SET identity 来设置它。This variable is a synonym for the last_insert_id variable. It exists for compatibility with other database systems. You can read its value with SELECT @@identity, and set it using SET identity.

  • init_connect

    命令行格式Command-Line Format --init-connect=name
    系统变量System Variable init_connect
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    每当有客户端连接时,服务器将执行的字符串。该字符串由一个或多个 SQL 语句组成,语句之间用分号分隔。A string to be executed by the server for each client that connects. The string consists of one or more SQL statements, separated by semicolon characters.

    For users that have the CONNECTION_ADMIN privilege (or the deprecated SUPER privilege), the content of init_connect is not executed. This is done so that an erroneous value for init_connect does not prevent all clients from connecting. For example, the value might contain a statement that has a syntax error, thus causing client connections to fail. Not executing init_connect for users that have the CONNECTION_ADMIN或者SUPER privilege enables them to open a connection and fix the init_connect value.For users that have the CONNECTION_ADMIN privilege (or the deprecated SUPER privilege), the content of init_connect is not executed. This is done so that an erroneous value for init_connect does not prevent all clients from connecting. For example, the value might contain a statement that has a syntax error, thus causing client connections to fail. Not executing init_connect for users that have the CONNECTION_ADMIN or SUPER privilege enables them to open a connection and fix the init_connect value.

    init_connect 的执行会被跳过,如果客户端用户的密码已过期。这样做的原因是此类用户无法执行任意语句,因此 init_connect 执行会失败,导致客户端无法连接。跳过 init_connect 的执行可以让用户连接并更改密码。init_connect execution is skipped for any client user with an expired password. This is done because such a user cannot execute arbitrary statements, and thus init_connect execution fails, leaving the client unable to connect. Skipping init_connect execution enables the user to connect and change password.

    服务器会丢弃由 init_connect 值中的语句产生的任何结果集。The server discards any result sets produced by statements in the value of init_connect.

  • information_schema_stats_expiry

    命令行格式Command-Line Format --information-schema-stats-expiry=#
    系统变量System Variable information_schema_stats_expiry
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 86400
    最小值Minimum Value 0
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    一些 INFORMATION_SCHEMA 表包含提供表统计信息的列:Some INFORMATION_SCHEMA tables contain columns that provide table statistics:

    STATISTICS.CARDINALITY
    TABLES.AUTO_INCREMENT
    TABLES.AVG_ROW_LENGTH
    TABLES.CHECKSUM
    TABLES.CHECK_TIME
    TABLES.CREATE_TIME
    TABLES.DATA_FREE
    TABLES.DATA_LENGTH
    TABLES.INDEX_LENGTH
    TABLES.MAX_DATA_LENGTH
    TABLES.TABLE_ROWS
    TABLES.UPDATE_TIME
    

    那些列表示动态表元数据;也就是说,随着表内容的变化而变化的信息。Those columns represent dynamic table metadata; that is, information that changes as table contents change.

    默认情况下,当查询这些列时,MySQL 会从 mysql.index_stats 和 mysql.table_stats 字典表中检索缓存的值,这比直接从存储引擎检索统计信息更高效。如果缓存的统计信息不可用或已过期,MySQL 会从存储引擎检索最新的统计信息并将其缓存到 mysql.index_stats 和 mysql.table_stats 字典表中。随后查询会检索缓存的统计信息,直到缓存的统计信息过期。服务器重启或首次打开 mysql.index_stats 和 mysql.table_stats 表并不会自动更新缓存的统计信息。By default, MySQL retrieves cached values for those columns from the mysql.index_stats and mysql.table_stats dictionary tables when the columns are queried, which is more efficient than retrieving statistics directly from the storage engine. If cached statistics are not available or have expired, MySQL retrieves the latest statistics from the storage engine and caches them in the mysql.index_stats and mysql.table_stats dictionary tables. Subsequent queries retrieve the cached statistics until the cached statistics expire. A server restart or the first opening of the mysql.index_stats and mysql.table_stats tables do not update cached statistics automatically.

    information_schema_stats_expiry 会话变量定义了缓存统计数据过期的时间周期。默认值为 86400 秒(24 小时),但该时间周期可以延长至最多一年。The information_schema_stats_expiry session variable defines the period of time before cached statistics expire. The default is 86400 seconds (24 hours), but the time period can be extended to as much as one year.

    要在任意时间更新给定表的缓存值,请使用 ANALYZE TABLE。To update cached values at any time for a given table, use ANALYZE TABLE.

    要始终直接从存储引擎获取最新的统计信息并绕过缓存值,请将 information_schema_stats_expiry 设置为 0。To always retrieve the latest statistics directly from the storage engine and bypass cached values, set information_schema_stats_expiry to 0.

    在以下情况下查询统计信息列不会在 mysql.index_stats 和 mysql.table_stats 字典表中存储或更新统计信息:Querying statistics columns does not store or update statistics in the mysql.index_stats and mysql.table_stats dictionary tables under these circumstances:

    在多语句事务期间,统计缓存可能会被更新,此时尚未确定事务是否提交。因此,缓存中可能包含与已知提交状态不对应的信息。这可能发生在 autocommit=0 或 START TRANSACTION 之后。The statistics cache may be updated during a multiple-statement transaction before it is known whether the transaction commits. As a result, the cache may contain information that does not correspond to a known committed state. This can occur with autocommit=0 or after START TRANSACTION.

    information_schema_stats_expiry 是一个会话变量,每个客户端会话可以定义自己的过期值。从存储引擎检索并由一个会话缓存的统计信息对其他会话也是可用的。information_schema_stats_expiry is a session variable, and each client session can define its own expiration value. Statistics that are retrieved from the storage engine and cached by one session are available to other sessions.

    有关相关信息,请参见 第 10.2.3 节,“优化 INFORMATION_SCHEMA 查询”。For related information, see Section 10.2.3, “Optimizing INFORMATION_SCHEMA Queries”.

  • init_file

    命令行格式Command-Line Format --init-file=file_name--init-file=file_name
    系统变量System Variable init_file
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name

    如果指定,此变量命名一个文件,该文件包含将在启动过程中读取和执行的 SQL 语句。此文件中语句的可接受格式支持以下结构:If specified, this variable names a file containing SQL statements to be read and executed during the startup process. The acceptable format for statements in this file support the following constructs:

    • delimiter ;,将语句分隔符设置为;字符。delimiter ;, to set the statement delimiter to the ; character.

    • delimiter $$,将语句分隔符设置为$$字符序列。delimiter $$, to set the statement delimiter to the $$ character sequence.

    • 同一行上的多个语句,由当前分隔符分隔。Multiple statements on the same line, delimited by the current delimiter.

    • 多行语句。Multiple-line statements.

    • 从 # 字符到行尾的注释。Comments from a # character to the end of the line.

    • 从 -- 序列到行尾的注释。Comments from a --  sequence to the end of the line.

    • C 风格的注释,从 /* 序列到随后的 */ 序列,包括跨多行的情况。C-style comments from a /* sequence to the following */ sequence, including over multiple lines.

    • 多行字符串字面量,可用单引号 (') 或双引号 (") 括起来。Multiple-line string literals enclosed within either single quote (') or double quote (") characters.

    如果服务器使用 --initialize 或 --initialize-insecure 选项启动,它将以引导模式运行,并且某些功能不可用,这限制了文件中允许的语句。这些语句包括与账户管理相关的语句(例如 CREATE USER 或 GRANT)、复制以及全局事务标识符。请参见 第 19.1.3 节,“使用全局事务标识符的复制”。If the server is started with the --initialize or --initialize-insecure option, it operates in bootstrap mode and some functionality is unavailable that limits the statements permitted in the file. These include statements that relate to account management (such as CREATE USER or GRANT), replication, and global transaction identifiers. See Section 19.1.3, “Replication with Global Transaction Identifiers”.

    在服务器启动期间创建的线程用于诸如创建数据字典、运行升级程序以及创建系统表等任务。为了确保环境的稳定性和可预测性,这些线程将使用服务器内置的默认值执行某些系统变量,例如 sql_mode、character_set_server、collation_server、completion_type、explicit_defaults_for_timestamp 以及 default_table_encryption。Threads created during server startup are used for tasks such as creating the data dictionary, running upgrade procedures, and creating system tables. To ensure a stable and predictable environment, these threads are executed with the server built-in defaults for some system variables, such as sql_mode, character_set_server, collation_server, completion_type, explicit_defaults_for_timestamp, and default_table_encryption.

    这些线程也用于执行在启动服务器时通过 init_file 指定的任何文件中的语句,因此这些语句会使用服务器内置的系统变量默认值执行。These threads are also used to execute the statements in any file specified with init_file when starting the server, so such statements execute with the server's built-in default values for those system variables.

  • innodb_xxx

    InnoDB 系统变量列在 第 17.14 节,“InnoDB 启动选项和系统变量” 中。这些变量控制 InnoDB 表的存储、内存使用和 I/O 模式的许多方面,并且由于 InnoDB 现在是默认的存储引擎,这些变量尤其重要。InnoDB system variables are listed in Section 17.14, “InnoDB Startup Options and System Variables”. These variables control many aspects of storage, memory use, and I/O patterns for InnoDB tables, and are especially important now that InnoDB is the default storage engine.

  • insert_id

    在使用以下 INSERT 或 ALTER TABLE 语句插入 AUTO_INCREMENT 值时要使用的值。这主要用于二进制日志。The value to be used by the following INSERT or ALTER TABLE statement when inserting an AUTO_INCREMENT value. This is mainly used with the binary log.

  • interactive_timeout

    命令行格式Command-Line Format --interactive-timeout=#
    系统变量System Variable interactive_timeout
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 28800
    最小值Minimum Value 1
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    服务器在关闭交互连接之前等待活动的秒数。交互客户端定义为使用 CLIENT_INTERACTIVE 选项通过 mysql_real_connect() 连接的客户端。另请参见 wait_timeout。The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option to mysql_real_connect(). See also wait_timeout.

  • internal_tmp_mem_storage_engine

    命令行格式Command-Line Format --internal-tmp-mem-storage-engine=#
    系统变量System Variable internal_tmp_mem_storage_engine
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 枚举Enumeration
    默认值Default Value TempTableTempTable
    有效值Valid Values

    MEMORYMEMORY

    TempTableTempTable

    用于内存中内部临时表的存储引擎(参见 第 10.4.4 节,“MySQL 中的内部临时表使用”)。允许的值为 TempTable(默认值)和 MEMORY。The storage engine for in-memory internal temporary tables (see Section 10.4.4, “Internal Temporary Table Use in MySQL”). Permitted values are TempTable (the default) and MEMORY.

    优化器 使用由 internal_tmp_mem_storage_engine 定义的存储引擎来处理内存中的内部临时表。The optimizer uses the storage engine defined by internal_tmp_mem_storage_engine for in-memory internal temporary tables.

    配置 internal_tmp_mem_storage_engine 的会话设置需要 SESSION_VARIABLES_ADMIN 或 SYSTEM_VARIABLES_ADMIN 权限。Configuring a session setting for internal_tmp_mem_storage_engine requires the SESSION_VARIABLES_ADMIN or SYSTEM_VARIABLES_ADMIN privilege.

  • join_buffer_size

    命令行格式Command-Line Format --join-buffer-size=#
    系统变量System Variable join_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 262144
    最小值Minimum Value 128
    最大值(Windows)Maximum Value (Windows) 4294967168
    最大值(其他,64 位平台)Maximum Value (Other, 64-bit platforms) 18446744073709551488
    最大值(其他,32 位平台)Maximum Value (Other, 32-bit platforms) 4294967168
    单位Unit 字节bytes
    块大小Block Size 128

    用于普通索引扫描、范围索引扫描以及不使用索引从而执行全表扫描的连接操作的缓冲区的最小大小。此变量还控制用于哈希连接的内存量。通常,获得快速连接的最佳方法是添加索引。当无法添加索引时,通过增加 join_buffer_size 的值,可以获得更快的全表连接速度。每对表之间的全表连接都会分配一个连接缓冲区。对于多个表之间的复杂连接且不使用索引的情况,可能需要多个连接缓冲区。The minimum size of the buffer that is used for plain index scans, range index scans, and joins that do not use indexes and thus perform full table scans. This variable also controls the amount of memory used for hash joins. Normally, the best way to get fast joins is to add indexes. Increase the value of join_buffer_size to get a faster full join when adding indexes is not possible. One join buffer is allocated for each full join between two tables. For a complex join between several tables for which indexes are not used, multiple join buffers might be necessary.

    默认值为 256KB。join_buffer_size 的最大允许设置为 4GB−1。对于 64 位平台允许更大的值(除了 64 位 Windows,对于其,大值会被截断为 4GB−1 并发出警告)。块大小为 128,MySQL 服务器在存储系统变量的值之前,会将不是块大小整数倍的值向下舍入到最接近的低于它的块大小整数倍。解析器允许的值最高可达平台的最大无符号整数值(对于 32 位系统为 4294967295 或 232−1,对于 64 位系统为 18446744073709551615 或 264−1),但实际最大值比它低一个块大小。The default is 256KB. The maximum permissible setting for join_buffer_size is 4GB−1. Larger values are permitted for 64-bit platforms (except 64-bit Windows, for which large values are truncated to 4GB−1 with a warning). The block size is 128, and a value that is not an exact multiple of the block size is rounded down to the next lower multiple of the block size by MySQL Server before storing the value for the system variable. The parser allows values up to the maximum unsigned integer value for the platform (4294967295 or 232−1 for a 32-bit system, 18446744073709551615 or 264−1 for a 64-bit system) but the actual maximum is a block size lower.

    除非使用了块嵌套循环(Block Nested-Loop)或批量键访问(Batched Key Access)算法,否则将缓冲区设置得比保存每个匹配行所需的大并不会带来任何收益,并且所有联接至少分配最小大小,因此在全局将此变量设置为较大值时要谨慎。最好保持全局设置较小,仅在进行大型联接的会话中将会话设置改为较大值,或者通过使用SET_VAR优化器提示(参见第 10.9.3 节,“优化器提示”)按查询单独更改设置。如果全局大小超过大多数使用它的查询所需,内存分配时间可能会导致性能显著下降。Unless a Block Nested-Loop or Batched Key Access algorithm is used, there is no gain from setting the buffer larger than required to hold each matching row, and all joins allocate at least the minimum size, so use caution in setting this variable to a large value globally. It is better to keep the global setting small and change the session setting to a larger value only in sessions that are doing large joins, or change the setting on a per-query basis by using a SET_VAR optimizer hint (see Section 10.9.3, “Optimizer Hints”). Memory allocation time can cause substantial performance drops if the global size is larger than needed by most queries that use it.

    当使用块嵌套循环(Block Nested-Loop)时,更大的连接缓冲区可能会有益,直到第一张表中所有行所需的所有列都存储在连接缓冲区中为止。这取决于查询;最佳大小可能比存储第一张表的所有行要小。When Block Nested-Loop is used, a larger join buffer can be beneficial up to the point where all required columns from all rows in the first table are stored in the join buffer. This depends on the query; the optimal size may be smaller than holding all rows from the first tables.

    当使用批量键访问时,join_buffer_size 的值定义了每次请求存储引擎时键的批量大小。缓冲区越大,对连接操作右表的顺序访问就越多,这可以显著提高性能。When Batched Key Access is used, the value of join_buffer_size defines how large the batch of keys is in each request to the storage engine. The larger the buffer, the more sequential access is made to the right hand table of a join operation, which can significantly improve performance.

    有关联接缓冲的更多信息,请参见第 10.2.1.7 节,“嵌套循环连接算法”。有关批量键访问的信息,请参见第 10.2.1.12 节,“块嵌套循环和批量键访问连接”。有关哈希连接的信息,请参见第 10.2.1.4 节,“哈希连接优化”。For additional information about join buffering, see Section 10.2.1.7, “Nested-Loop Join Algorithms”. For information about Batched Key Access, see Section 10.2.1.12, “Block Nested-Loop and Batched Key Access Joins”. For information about hash joins, see Section 10.2.1.4, “Hash Join Optimization”.

  • keep_files_on_create

    命令行格式Command-Line Format --keep-files-on-create[={OFF|ON}]
    系统变量System Variable keep_files_on_create
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果创建 MyISAM 表时未指定 DATA DIRECTORY 选项,.MYD 文件将创建在数据库目录中。默认情况下,如果 MyISAM 在此情况发现已有的 .MYD 文件,它会覆盖该文件。同样,对于未指定 .MYI 选项创建的表,INDEX DIRECTORY 文件也适用此规则。要抑制此行为,可将 keep_files_on_create 变量设置为 ON(1),此时 MyISAM 不会覆盖已有文件,而是返回错误。默认值为 OFF(0)。If a MyISAM table is created with no DATA DIRECTORY option, the .MYD file is created in the database directory. By default, if MyISAM finds an existing .MYD file in this case, it overwrites it. The same applies to .MYI files for tables created with no INDEX DIRECTORY option. To suppress this behavior, set the keep_files_on_create variable to ON (1), in which case MyISAM does not overwrite existing files and returns an error instead. The default value is OFF (0).

    如果使用 DATA DIRECTORY 或 MyISAM 选项创建 INDEX DIRECTORY 表,并且发现已有的 .MYD 或 .MYI 文件,MyISAM 总是返回错误。它不会覆盖指定目录中的文件。If a MyISAM table is created with a DATA DIRECTORY or INDEX DIRECTORY option and an existing .MYD or .MYI file is found, MyISAM always returns an error. It does not overwrite a file in the specified directory.

  • key_buffer_size

    命令行格式Command-Line Format --key-buffer-size=#
    系统变量System Variable key_buffer_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8388608
    最小值Minimum Value 0
    最大值(64 位平台)Maximum Value (64-bit platforms) OS_PER_PROCESS_LIMIT
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295
    单位Unit 字节bytes

    MyISAM 表的索引块被缓冲,并且由所有线程共享。key_buffer_size 是用于索引块缓冲区的大小。键缓冲区也被称为键缓存。Index blocks for MyISAM tables are buffered and are shared by all threads. key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.

    最小允许设置为 0,但您不能在动态情况下将 key_buffer_size 设置为 0。设置为 0 会清空键缓存,这是在运行时不允许的。仅在启动时允许将 key_buffer_size 设置为 0,此时键缓存不会被初始化。在运行时将 key_buffer_size 从 0 改为允许的非零值会初始化键缓存。The minimum permissible setting is 0, but you cannot set key_buffer_size to 0 dynamically. A setting of 0 drops the key cache, which is not permitted at runtime. Setting key_buffer_size to 0 is permitted only at startup, in which case the key cache is not initialized. Changing the key_buffer_size setting at runtime from a value of 0 to a permitted non-zero value initializes the key cache.

    key_buffer_size 只能以 4096 字节的增量或倍数来增加或减少。以不符合增量的值增加或减少该设置会产生警告,并将该设置截断为符合要求的值。key_buffer_size can be increased or decreased only in increments or multiples of 4096 bytes. Increasing or decreasing the setting by a nonconforming value produces a warning and truncates the setting to a conforming value.

    key_buffer_size 在 32 位平台上的最大允许设置是 4GB−1。对 64 位平台允许更大的值。有效的最大大小可能更小,这取决于您可用的物理内存以及操作系统或硬件平台施加的每个进程内存限制。该变量的值表示请求的内存量。内部,服务器会分配尽可能多的内存,最多不超过此值,但实际分配的内存可能更少。The maximum permissible setting for key_buffer_size is 4GB−1 on 32-bit platforms. Larger values are permitted for 64-bit platforms. The effective maximum size might be less, depending on your available physical RAM and per-process RAM limits imposed by your operating system or hardware platform. The value of this variable indicates the amount of memory requested. Internally, the server allocates as much memory as possible up to this amount, but the actual allocation might be less.

    您可以增加该值以获得更好的索引处理性能,适用于所有读取和多次写入;在一个主要用于运行使用 MyISAM 存储引擎的 MySQL 系统上,将该变量设置为机器总内存的 25% 是一个可接受的值。然而,您应该注意,如果将该值设得过大(例如,超过机器总内存的 50%),系统可能开始分页并变得极其缓慢。这是因为 MySQL 依赖操作系统执行数据读取的文件系统缓存,因此您必须为文件系统缓存留出一些空间。您还应考虑除了 MyISAM 之外,您可能使用的其他存储引擎的内存需求。You can increase the value to get better index handling for all reads and multiple writes; on a system whose primary function is to run MySQL using the MyISAM storage engine, 25% of the machine's total memory is an acceptable value for this variable. However, you should be aware that, if you make the value too large (for example, more than 50% of the machine's total memory), your system might start to page and become extremely slow. This is because MySQL relies on the operating system to perform file system caching for data reads, so you must leave some room for the file system cache. You should also consider the memory requirements of any other storage engines that you may be using in addition to MyISAM.

    为了在同时写入多行时获得更高的速度,请使用 LOCK TABLES。参见 第 10.2.5.1 节,“优化 INSERT 语句”。For even more speed when writing many rows at the same time, use LOCK TABLES. See Section 10.2.5.1, “Optimizing INSERT Statements”.

    您可以通过发出 SHOW STATUS 语句并查看 Key_read_requests、Key_reads、Key_write_requests 和 Key_writes 状态变量来检查键缓冲区的性能。 (参见 第 15.7.7 节,“SHOW 语句”。) Key_reads/Key_read_requests 的比率通常应小于 0.01。如果您主要使用更新和删除操作,Key_writes/Key_write_requests 的比率通常接近 1,但如果您倾向于进行影响多行的更新,或者使用 DELAY_KEY_WRITE 表选项,该比率可能会小得多。You can check the performance of the key buffer by issuing a SHOW STATUS statement and examining the Key_read_requests, Key_reads, Key_write_requests, and Key_writes status variables. (See Section 15.7.7, “SHOW Statements”.) The Key_reads/Key_read_requests ratio should normally be less than 0.01. The Key_writes/Key_write_requests ratio is usually near 1 if you are using mostly updates and deletes, but might be much smaller if you tend to do updates that affect many rows at the same time or if you are using the DELAY_KEY_WRITE table option.

    可以使用 key_buffer_size 结合 Key_blocks_unused 状态变量以及可通过 key_cache_block_size 系统变量获得的缓冲区块大小来确定关键缓冲区的使用比例:The fraction of the key buffer in use can be determined using key_buffer_size in conjunction with the Key_blocks_unused status variable and the buffer block size, which is available from the key_cache_block_size system variable:

    1 - ((Key_blocks_unused * key_cache_block_size) / key_buffer_size)
    

    此值是一个近似值,因为键缓冲区中的部分空间被内部分配用于管理结构。影响这些结构开销量的因素包括块大小和指针大小。随着块大小的增加,缓冲区因开销损失的百分比往往会减少。较大的块会导致读取操作次数较少(因为每次读取获取的键更多),但反过来,如果块中并非所有键都与查询相关,则可能增加未被检查键的读取次数。This value is an approximation because some space in the key buffer is allocated internally for administrative structures. Factors that influence the amount of overhead for these structures include block size and pointer size. As block size increases, the percentage of the key buffer lost to overhead tends to decrease. Larger blocks results in a smaller number of read operations (because more keys are obtained per read), but conversely an increase in reads of keys that are not examined (if not all keys in a block are relevant to a query).

    可以创建多个 MyISAM 键缓存。4GB 的大小限制适用于每个缓存,而不是整个组。请参见 第 10.10.2 节,“MyISAM 键缓存”。It is possible to create multiple MyISAM key caches. The size limit of 4GB applies to each cache individually, not as a group. See Section 10.10.2, “The MyISAM Key Cache”.

  • key_cache_age_threshold

    命令行格式Command-Line Format --key-cache-age-threshold=#
    系统变量System Variable key_cache_age_threshold
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 300
    最小值Minimum Value 100
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551516
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967196
    块大小Block Size 100

    此值控制缓冲区从键缓存的热子列表降级到温子列表。较低的值会导致降级更快发生。最小值为 100。默认值为 300。参见 第 10.10.2 节,“MyISAM 键缓存”。This value controls the demotion of buffers from the hot sublist of a key cache to the warm sublist. Lower values cause demotion to happen more quickly. The minimum value is 100. The default value is 300. See Section 10.10.2, “The MyISAM Key Cache”.

  • key_cache_block_size

    命令行格式Command-Line Format --key-cache-block-size=#
    系统变量System Variable key_cache_block_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1024
    最小值Minimum Value 512
    最大值Maximum Value 16384
    单位Unit 字节bytes
    块大小Block Size 512

    键缓存中块的字节大小。默认值为 1024。参见 第 10.10.2 节,“MyISAM 键缓存”。The size in bytes of blocks in the key cache. The default value is 1024. See Section 10.10.2, “The MyISAM Key Cache”.

  • key_cache_division_limit

    命令行格式Command-Line Format --key-cache-division-limit=#
    系统变量System Variable key_cache_division_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 100
    最小值Minimum Value 1
    最大值Maximum Value 100

    键缓存缓冲列表的热子列表和温子列表之间的分界点。该值为用于温子列表的缓冲列表百分比。允许值范围为 1 到 100。默认值为 100。参见 第 10.10.2 节,“MyISAM 键缓存”。The division point between the hot and warm sublists of the key cache buffer list. The value is the percentage of the buffer list to use for the warm sublist. Permissible values range from 1 to 100. The default value is 100. See Section 10.10.2, “The MyISAM Key Cache”.

  • large_files_support

    系统变量System Variable large_files_support
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean

    mysqld 是否已使用大文件支持选项进行编译。Whether mysqld was compiled with options for large file support.

  • large_pages

    命令行格式Command-Line Format --large-pages[={OFF|ON}]
    系统变量System Variable large_pages
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific Linux
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    是否启用了大页支持(通过 --large-pages 选项)。参见 第 10.12.3.3 节,“启用大页支持”。Whether large page support is enabled (via the --large-pages option). See Section 10.12.3.3, “Enabling Large Page Support”.

  • large_page_size

    系统变量System Variable large_page_size
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 65535
    单位Unit 字节bytes

    如果启用了大页支持,则显示内存页的大小。大页内存仅在 Linux 上受支持;在其他平台上,该变量的值始终为 0。参见 第 10.12.3.3 节,“启用大页支持”。If large page support is enabled, this shows the size of memory pages. Large memory pages are supported only on Linux; on other platforms, the value of this variable is always 0. See Section 10.12.3.3, “Enabling Large Page Support”.

  • last_insert_id

    要从LAST_INSERT_ID()返回的值。当你在更新表的语句中使用LAST_INSERT_ID()时,它会被存储在二进制日志中。设置该变量不会更新mysql_insert_id() C API 函数返回的值。The value to be returned from LAST_INSERT_ID(). This is stored in the binary log when you use LAST_INSERT_ID() in a statement that updates a table. Setting this variable does not update the value returned by the mysql_insert_id() C API function.

  • lc_messages

    命令行格式Command-Line Format --lc-messages=name
    系统变量System Variable lc_messages
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value en_US

    用于错误消息的区域设置。默认值为en_US。服务器将该参数转换为语言名称,并将其与lc_messages_dir的值结合,以生成错误消息文件的位置。参见第 12.12 节,“设置错误消息语言”。The locale to use for error messages. The default is en_US. The server converts the argument to a language name and combines it with the value of lc_messages_dir to produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.

  • lc_messages_dir

    命令行格式Command-Line Format --lc-messages-dir=dir_name
    系统变量System Variable lc_messages_dir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    存放错误信息的目录。服务器将该值与 lc_messages 的值一起使用,以生成错误信息文件的位置。参见 第 12.12 节,“设置错误信息语言”。The directory where error messages are located. The server uses the value together with the value of lc_messages to produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.

  • lc_time_names

    命令行格式Command-Line Format --lc-time-names=value--lc-time-names=value
    系统变量System Variable lc_time_names
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    此变量指定用于显示日期和月份名称及缩写的语言环境。该变量会影响 DATE_FORMAT()、DAYNAME() 和 MONTHNAME() 函数的输出。语言环境名称是 POSIX 风格的值,例如 'ja_JP' 或 'pt_BR'。默认值是 'en_US',与系统的语言环境设置无关。有关更多信息,请参见 第 12.16 节,“MySQL 服务器语言环境支持”。This variable specifies the locale that controls the language used to display day and month names and abbreviations. This variable affects the output from the DATE_FORMAT(), DAYNAME() and MONTHNAME() functions. Locale names are POSIX-style values such as 'ja_JP' or 'pt_BR'. The default value is 'en_US' regardless of your system's locale setting. For further information, see Section 12.16, “MySQL Server Locale Support”.

  • license license

    系统变量System Variable licenselicense
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value GPL

    服务器拥有的许可证类型。The type of license the server has.

  • local_infile

    命令行格式Command-Line Format --local-infile[={OFF|ON}]
    系统变量System Variable local_infile
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    该变量控制服务器端 LOCAL 功能,用于 LOAD DATA 语句。根据 local_infile 的设置,服务器会拒绝或允许客户端在客户端启用了 LOCAL 的情况下加载本地数据。This variable controls server-side LOCAL capability for LOAD DATA statements. Depending on the local_infile setting, the server refuses or permits local data loading by clients that have LOCAL enabled on the client side.

    要显式地使服务器拒绝或允许LOAD DATA LOCAL语句(无论客户端程序和库在构建时或运行时如何配置),请以禁用或启用local_infile的方式启动mysqld。local_infile也可以在运行时设置。有关更多信息,请参见第 8.1.6 节,“LOAD DATA LOCAL 的安全注意事项”。To explicitly cause the server to refuse or permit LOAD DATA LOCAL statements (regardless of how client programs and libraries are configured at build time or runtime), start mysqld with local_infile disabled or enabled, respectively. local_infile can also be set at runtime. For more information, see Section 8.1.6, “Security Considerations for LOAD DATA LOCAL”.

  • lock_wait_timeout

    命令行格式Command-Line Format --lock-wait-timeout=#
    系统变量System Variable lock_wait_timeout
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 31536000
    最小值Minimum Value 1
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    此变量指定尝试获取元数据锁的超时时间(以秒为单位)。允许的值范围是 1 到 31536000(1 年)。默认值为 31536000。This variable specifies the timeout in seconds for attempts to acquire metadata locks. The permissible values range from 1 to 31536000 (1 year). The default is 31536000.

    此超时适用于所有使用元数据锁的语句。这些包括对表、视图、存储过程和存储函数的 DML 和 DDL 操作,以及 LOCK TABLES、FLUSH TABLES WITH READ LOCK 和 HANDLER 语句。This timeout applies to all statements that use metadata locks. These include DML and DDL operations on tables, views, stored procedures, and stored functions, as well as LOCK TABLES, FLUSH TABLES WITH READ LOCK, and HANDLER statements.

    此超时不适用于对 mysql 数据库中的系统表的隐式访问,例如由 GRANT 或 REVOKE 语句或表日志语句修改的授权表。超时适用于直接访问的系统表,例如使用 SELECT 或 UPDATE。This timeout does not apply to implicit accesses to system tables in the mysql database, such as grant tables modified by GRANT or REVOKE statements or table logging statements. The timeout does apply to system tables accessed directly, such as with SELECT or UPDATE.

    超时值分别适用于每次元数据锁尝试。一个给定的语句可能需要多个锁,因此在报告超时错误之前,该语句可能会阻塞的时间超过 lock_wait_timeout 的值。当锁超时时,会报告 ER_LOCK_WAIT_TIMEOUT。The timeout value applies separately for each metadata lock attempt. A given statement can require more than one lock, so it is possible for the statement to block for longer than the lock_wait_timeout value before reporting a timeout error. When lock timeout occurs, ER_LOCK_WAIT_TIMEOUT is reported.

    lock_wait_timeout 也定义了 LOCK INSTANCE FOR BACKUP 语句在放弃之前等待锁的时间。lock_wait_timeout also defines the amount of time that a LOCK INSTANCE FOR BACKUP statement waits for a lock before giving up.

  • locked_in_memory locked_in_memory

    系统变量System Variable locked_in_memorylocked_in_memory
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    无论 mysqld 是否通过 --memlock 锁定在内存中。Whether mysqld was locked in memory with --memlock.

  • log_error log_error

    命令行格式Command-Line Format --log-error[=file_name]--log-error[=file_name]
    系统变量System Variable log_error
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name

    默认的错误日志目标。如果目标是控制台,则值为 stderr。否则,目标是一个文件,并且 log_error 的值为文件名。参见 第 7.4.2 节,“错误日志”。The default error log destination. If the destination is the console, the value is stderr. Otherwise, the destination is a file and the log_error value is the file name. See Section 7.4.2, “The Error Log”.

  • log_error_services log_error_services

    命令行格式Command-Line Format --log-error-services=value--log-error-services=value
    系统变量System Variable log_error_serviceslog_error_services
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value log_filter_internal; log_sink_internallog_filter_internal; log_sink_internal

    启用错误日志记录的组件。该变量可能包含一个包含 0、1 或多个元素的列表。在后一种情况下,元素可以用分号或逗号分隔,后面可选跟空格。给定的设置不能同时使用分号和逗号作为分隔符。组件的顺序很重要,因为服务器按列表中的顺序执行组件。The components to enable for error logging. The variable may contain a list with 0, 1, or many elements. In the latter case, elements may be delimited by semicolons or commas, optionally followed by space. A given setting cannot use both semicolon and comma separators. Component order is significant because the server executes components in the order listed.

    任何在 log_error_services 中指定的可加载(非内置)组件,如果尚未加载,将被隐式加载。有关更多信息,请参见 第 7.4.2.1 节,“错误日志配置”。Any loadable (not built in) component named in log_error_services is implicitly loaded if it is not already loaded. For more information, see Section 7.4.2.1, “Error Log Configuration”.

  • log_error_suppression_list

    命令行格式Command-Line Format --log-error-suppression-list=value
    系统变量System Variable log_error_suppression_list
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value empty stringempty string

    log_error_suppression_list 系统变量适用于计划写入错误日志的事件,并指定在事件具有 WARNING 或 INFORMATION 优先级时应抑制哪些事件。例如,如果某种类型的警告被认为在错误日志中是不希望出现的“噪音”,因为它出现频繁但没有实际意义,则可以对其进行抑制。该变量影响由 log_filter_internal 错误日志过滤组件执行的过滤操作,该组件默认启用(参见 第 7.5.3 节,“错误日志组件”)。如果 log_filter_internal 被禁用,log_error_suppression_list 将不起作用。The log_error_suppression_list system variable applies to events intended for the error log and specifies which events to suppress when they occur with a priority of WARNING or INFORMATION. For example, if a particular type of warning is considered undesirable “noise” in the error log because it occurs frequently but is not of interest, it can be suppressed. This variable affects filtering performed by the log_filter_internal error log filter component, which is enabled by default (see Section 7.5.3, “Error Log Components”). If log_filter_internal is disabled, log_error_suppression_list has no effect.

    log_error_suppression_list 的值可以是空字符串,表示不抑制,或者是一个或多个用逗号分隔的值的列表,表示要抑制的错误代码。错误代码可以用符号形式或数字形式指定。数字代码可以带或不带 MY- 前缀。数字部分的前导零不重要。允许的代码格式示例:The log_error_suppression_list value may be the empty string for no suppression, or a list of one or more comma-separated values indicating the error codes to suppress. Error codes may be specified in symbolic or numeric form. A numeric code may be specified with or without the MY- prefix. Leading zeros in the numeric part are not significant. Examples of permitted code formats:

    ER_SERVER_SHUTDOWN_COMPLETE
    MY-000031
    000031
    MY-31
    31
    

    符号值比数字值更可读且更具可移植性。有关允许的错误符号和编号的信息,请参见 MySQL 8.4 错误信息参考。Symbolic values are preferable to numeric values for readability and portability. For information about the permitted error symbols and numbers, see MySQL 8.4 Error Message Reference.

    log_error_suppression_list 的效果与 log_error_verbosity 的效果结合使用。有关更多信息,请参见 第 7.4.2.5 节,“基于优先级的错误日志过滤 (log_filter_internal)”。The effect of log_error_suppression_list combines with that of log_error_verbosity. For additional information, see Section 7.4.2.5, “Priority-Based Error Log Filtering (log_filter_internal)”.

  • log_error_verbosity

    命令行格式Command-Line Format --log-error-verbosity=#
    系统变量System Variable log_error_verbosity
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 2
    最小值Minimum Value 1
    最大值Maximum Value 3

    log_error_verbosity 系统变量指定处理发送到错误日志的事件的详细程度。该变量会影响由 log_filter_internal 错误日志过滤组件执行的过滤操作,该组件默认启用(参见第 7.5.3 节,“错误日志组件”)。如果 log_filter_internal 被禁用,log_error_verbosity 将不起作用。The log_error_verbosity system variable specifies the verbosity for handling events intended for the error log. This variable affects filtering performed by the log_filter_internal error log filter component, which is enabled by default (see Section 7.5.3, “Error Log Components”). If log_filter_internal is disabled, log_error_verbosity has no effect.

    记录到错误日志的事件优先级为ERROR、WARNING或INFORMATION。log_error_verbosity根据允许写入日志的消息优先级来控制详细程度,如下表所示。Events intended for the error log have a priority of ERROR, WARNING, or INFORMATION. log_error_verbosity controls verbosity based on which priorities to permit for messages written to the log, as shown in the following table.

    log_error_verbosity 值log_error_verbosity Value 允许的消息优先级Permitted Message Priorities
    1 ERRORERROR
    2 ERROR, WARNINGERROR, WARNING
    3 ERROR, WARNING, INFORMATIONERROR, WARNING, INFORMATION

    还有一个优先级为 SYSTEM。关于非错误情况的系统消息会被记录到错误日志中,无论 log_error_verbosity 的值是多少。这些消息包括启动和关闭消息,以及一些重要的设置更改。There is also a priority of SYSTEM. System messages about non-error situations are printed to the error log regardless of the log_error_verbosity value. These messages include startup and shutdown messages, and some significant changes to settings.

    log_error_verbosity 的效果与 log_error_suppression_list 的效果结合使用。有关更多信息,请参阅 第 7.4.2.5 节,“基于优先级的错误日志过滤(log_filter_internal)”。The effect of log_error_verbosity combines with that of log_error_suppression_list. For additional information, see Section 7.4.2.5, “Priority-Based Error Log Filtering (log_filter_internal)”.

  • log_output

    命令行格式Command-Line Format --log-output=name
    系统变量System Variable log_output
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 设置Set
    默认值Default Value FILEFILE
    有效值Valid Values

    TABLETABLE

    FILEFILE

    NONENONE

    用于一般查询日志和慢查询日志输出的目标。该值是一个或多个以逗号分隔的单词列表,可从 TABLE、FILE 和 NONE 中选择。TABLE 选择将日志记录到 general_log 和 slow_log 表中,这些表位于 mysql 系统模式。FILE 选择将日志记录到日志文件。NONE 禁用日志记录。如果值中存在 NONE,则它优先于其他任何已存在的单词。TABLE 和 FILE 可以同时指定以选择两个日志输出目标。The destination or destinations for general query log and slow query log output. The value is a list one or more comma-separated words chosen from TABLE, FILE, and NONE. TABLE selects logging to the general_log and slow_log tables in the mysql system schema. FILE selects logging to log files. NONE disables logging. If NONE is present in the value, it takes precedence over any other words that are present. TABLE and FILE can both be given to select both log output destinations.

    此变量选择日志输出目标,但不会启用日志输出。要启用日志输出,请启用 general_log 和 slow_query_log 系统变量。对于 FILE 日志记录,general_log_file 和 slow_query_log_file 系统变量决定日志文件的位置。欲了解更多信息,请参阅 第 7.4.1 节,“选择常规查询日志和慢查询日志的输出目标”。This variable selects log output destinations, but does not enable log output. To do that, enable the general_log and slow_query_log system variables. For FILE logging, the general_log_file and slow_query_log_file system variables determine the log file locations. For more information, see Section 7.4.1, “Selecting General Query Log and Slow Query Log Output Destinations”.

  • log_queries_not_using_indexes

    命令行格式Command-Line Format --log-queries-not-using-indexes[={OFF|ON}]--log-queries-not-using-indexes[={OFF|ON}]
    系统变量System Variable log_queries_not_using_indexes
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果在启用慢查询日志的情况下启用此变量,则预期会检索所有行的查询将被记录。请参见 第 7.4.5 节,“慢查询日志”。此选项并不一定表示未使用索引。例如,使用完整索引扫描的查询会使用索引,但由于索引不会限制行数,因此仍会被记录。If you enable this variable with the slow query log enabled, queries that are expected to retrieve all rows are logged. See Section 7.4.5, “The Slow Query Log”. This option does not necessarily mean that no index is used. For example, a query that uses a full index scan uses an index but would be logged because the index would not limit the number of rows.

  • log_raw

    命令行格式Command-Line Format --log-raw[={OFF|ON}]--log-raw[={OFF|ON}]
    系统变量System Variable log_raw
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    log_raw 系统变量最初设置为 --log-raw 选项的值。有关更多信息,请参见该选项的描述。系统变量也可以在运行时设置,以更改密码掩码行为。The log_raw system variable is initially set to the value of the --log-raw option. See the description of that option for more information. The system variable may also be set at runtime to change password masking behavior.

  • log_slow_admin_statements

    命令行格式Command-Line Format --log-slow-admin-statements[={OFF|ON}]--log-slow-admin-statements[={OFF|ON}]
    系统变量System Variable log_slow_admin_statements
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    在写入慢查询日志的语句中包含慢速管理语句。管理语句包括 ALTER TABLE、ANALYZE TABLE、CHECK TABLE、CREATE INDEX、DROP INDEX、OPTIMIZE TABLE 和 REPAIR TABLE。Include slow administrative statements in the statements written to the slow query log. Administrative statements include ALTER TABLE, ANALYZE TABLE, CHECK TABLE, CREATE INDEX, DROP INDEX, OPTIMIZE TABLE, and REPAIR TABLE.

  • log_slow_extra

    命令行格式Command-Line Format --log-slow-extra[={OFF|ON}]
    系统变量System Variable log_slow_extra
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果启用了慢查询日志且输出目标包括FILE,服务器会向日志文件行写入附加字段,以提供有关慢查询语句的信息。请参见第 7.4.5 节,“慢查询日志”。TABLE输出不受影响。If the slow query log is enabled and the output destination includes FILE, the server writes additional fields to log file lines that provide information about slow statements. See Section 7.4.5, “The Slow Query Log”. TABLE output is unaffected.

  • log_timestamps

    命令行格式Command-Line Format --log-timestamps=#
    系统变量System Variable log_timestamps
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value UTCUTC
    有效值Valid Values

    UTCUTC

    SYSTEMSYSTEM

    此变量控制写入错误日志的消息以及写入文件的一般查询日志和慢查询日志消息的时间戳时区。它不会影响写入表(mysql.general_log,mysql.slow_log)的一般查询日志和慢查询日志消息的时区。从这些表中检索的行可以使用 CONVERT_TZ() 从本地系统时区转换为任何所需时区,或者通过设置会话 time_zone 系统变量来实现。This variable controls the time zone of timestamps in messages written to the error log, and in general query log and slow query log messages written to files. It does not affect the time zone of general query log and slow query log messages written to tables (mysql.general_log, mysql.slow_log). Rows retrieved from those tables can be converted from the local system time zone to any desired time zone with CONVERT_TZ() or by setting the session time_zone system variable.

    允许的 log_timestamps 值为 UTC(默认值)和 SYSTEM(本地系统时区)。Permitted log_timestamps values are UTC (the default) and SYSTEM (the local system time zone).

    时间戳使用 ISO 8601 / RFC 3339 格式记录:YYYY-MM-DDThh:mm:ss.uuuuuu,并附加尾部值 Z 表示 Zulu 时间(UTC)或 ±hh:mm(UTC 偏移)。Timestamps are written using ISO 8601 / RFC 3339 format: YYYY-MM-DDThh:mm:ss.uuuuuu plus a tail value of Z signifying Zulu time (UTC) or ±hh:mm (an offset from UTC).

  • log_throttle_queries_not_using_indexes

    命令行格式Command-Line Format --log-throttle-queries-not-using-indexes=#
    系统变量System Variable log_throttle_queries_not_using_indexes
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    如果启用了 log_queries_not_using_indexes,则 log_throttle_queries_not_using_indexes 变量限制每分钟可以写入慢查询日志的此类查询的数量。值为 0(默认值)表示“无限制”。有关更多信息,请参见 第 7.4.5 节,“慢查询日志”。If log_queries_not_using_indexes is enabled, the log_throttle_queries_not_using_indexes variable limits the number of such queries per minute that can be written to the slow query log. A value of 0 (the default) means “no limit”. For more information, see Section 7.4.5, “The Slow Query Log”.

  • long_query_time

    命令行格式Command-Line Format --long-query-time=#
    系统变量System Variable long_query_time
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 数字Numeric
    默认值Default Value 10
    最小值Minimum Value 0
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    如果查询所花费的时间超过此设定的秒数,服务器会增加 Slow_queries 状态变量。如果启用了慢查询日志,该查询将被记录到慢查询日志文件中。该值是以实时来衡量的,而不是 CPU 时间,因此在负载较轻的系统上低于阈值的查询,在负载较重的系统上可能会超过阈值。long_query_time 的最小值和默认值分别是 0 和 10。最大值是 31536000,即 365 天(秒)。该值可以指定到微秒精度。参见 第 7.4.5 节,“慢查询日志”。If a query takes longer than this many seconds, the server increments the Slow_queries status variable. If the slow query log is enabled, the query is logged to the slow query log file. This value is measured in real time, not CPU time, so a query that is under the threshold on a lightly loaded system might be above the threshold on a heavily loaded one. The minimum and default values of long_query_time are 0 and 10, respectively. The maximum is 31536000, which is 365 days in seconds. The value can be specified to a resolution of microseconds. See Section 7.4.5, “The Slow Query Log”.

    该变量的较小值会导致更多语句被视为长时间运行,从而需要更多空间记录慢查询日志。对于非常小的值(小于一秒),日志可能在短时间内迅速增大。增加被视为长时间运行的语句数量,也可能导致“长时间运行进程过多”在 MySQL 企业监控中发出警报,尤其是在启用组复制的情况下。出于这些原因,非常小的值应仅在测试环境中使用,或者在生产环境中仅在短时间内使用。Smaller values of this variable result in more statements being considered long-running, with the result that more space is required for the slow query log. For very small values (less than one second), the log may grow quite large in a small time. Increasing the number of statements considered long-running may also result in false positives for the “excessive Number of Long Running Processes” alert in MySQL Enterprise Monitor, especially if Group Replication is enabled. For these reasons, very small values should be used in test environments only, or, in production environments, only for a short period.

    mysqldump 执行完整的表扫描,这意味着它的查询经常会超出long_query_time设定值,而该设定对普通查询是有用的。如果你想在慢查询日志中排除大部分或全部由mysqldump 生成的查询,可以使用--mysqld-long-query-time 将系统变量的会话值调高。mysqldump performs a full table scan, which means its queries can often exceed a long_query_time setting that is useful for regular queries. If you want to exclude most or all of the queries generated by mysqldump from the slow query log, you can use --mysqld-long-query-time to change the session value of the system variable to a higher value.

  • low_priority_updates

    命令行格式Command-Line Format --low-priority-updates[={OFF|ON}]--low-priority-updates[={OFF|ON}]
    系统变量System Variable low_priority_updates
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果设置为1,所有INSERT、UPDATE、DELETE和LOCK TABLE WRITE语句将等待,直到受影响的表上没有待处理的SELECT或LOCK TABLE READ。使用{INSERT | REPLACE | DELETE | UPDATE} LOW_PRIORITY ...也可以获得相同效果,仅降低单个查询的优先级。此变量只影响使用表级锁的存储引擎(例如MyISAM、MEMORY和MERGE)。请参见第 10.11.2 节,“表锁问题”。If set to 1, all INSERT, UPDATE, DELETE, and LOCK TABLE WRITE statements wait until there is no pending SELECT or LOCK TABLE READ on the affected table. The same effect can be obtained using {INSERT | REPLACE | DELETE | UPDATE} LOW_PRIORITY ... to lower the priority of only one query. This variable affects only storage engines that use only table-level locking (such as MyISAM, MEMORY, and MERGE). See Section 10.11.2, “Table Locking Issues”.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • lower_case_file_system

    系统变量System Variable lower_case_file_system
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean

    该变量描述数据目录所在文件系统上文件名的大小写敏感性。OFF 表示文件名区分大小写,ON 表示不区分大小写。该变量为只读,因为它反映了文件系统的属性,设置它不会对文件系统产生影响。This variable describes the case sensitivity of file names on the file system where the data directory is located. OFF means file names are case-sensitive, ON means they are not case-sensitive. This variable is read only because it reflects a file system attribute and setting it would have no effect on the file system.

  • lower_case_table_names

    命令行格式Command-Line Format --lower-case-table-names[=#]
    系统变量System Variable lower_case_table_names
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值(macOS)Default Value (macOS) 2
    默认值(Unix)Default Value (Unix) 0
    默认值(Windows)Default Value (Windows) 1
    最小值Minimum Value 0
    最大值Maximum Value 2

    如果设置为 0,表名按指定方式存储,并且比较时区分大小写。如果设置为 1,表名在磁盘上以小写存储,并且比较时不区分大小写。如果设置为 2,表名按给定方式存储,但比较时转换为小写。此选项也适用于数据库名称和表别名。有关更多详情,请参见 第 11.2.3 节,“标识符大小写敏感性”。If set to 0, table names are stored as specified and comparisons are case-sensitive. If set to 1, table names are stored in lowercase on disk and comparisons are not case-sensitive. If set to 2, table names are stored as given but compared in lowercase. This option also applies to database names and table aliases. For additional details, see Section 11.2.3, “Identifier Case Sensitivity”.

    此变量的默认值依赖于平台(参见 lower_case_file_system)。在 Linux 及其他类 Unix 系统上,默认值为 0。在 Windows 上,默认值为 1。在 macOS 上,默认值为 2。在 Linux(及其他类 Unix 系统)上,将值设置为 2 不被支持;服务器会强制将值设置为 0。The default value of this variable is platform-dependent (see lower_case_file_system). On Linux and other Unix-like systems, the default is 0. On Windows the default value is 1. On macOS, the default value is 2. On Linux (and other Unix-like systems), setting the value to 2 is not supported; the server forces the value to 0 instead.

    你应该在多线程系统中设置lower_case_table_names为 0,如果你在数据目录位于大小写不敏感文件系统(例如 Windows 或 macOS)上的系统上运行 MySQL。这是一种不受支持的组合,可能在使用错误的INSERT INTO ... SELECT ... FROM tbl_name字母大小写进行操作时导致挂起情况。tbl_name使用MyISAM访问不同字母大小写的表名可能导致索引损坏。You should not set lower_case_table_names to 0 if you are running MySQL on a system where the data directory resides on a case-insensitive file system (such as on Windows or macOS). It is an unsupported combination that could result in a hang condition when running an INSERT INTO ... SELECT ... FROM tbl_name operation with the wrong tbl_name lettercase. With MyISAM, accessing table names using different lettercases could cause index corruption.

    如果您尝试在不区分大小写的文件系统上使用 --lower_case_table_names=0 启动服务器,则会打印错误消息并退出服务器。An error message is printed and the server exits if you attempt to start the server with --lower_case_table_names=0 on a case-insensitive file system.

    该变量的设置会影响复制过滤选项在大小写敏感方面的行为。更多信息,请参见 第 19.2.5 节,“服务器如何评估复制过滤规则”。The setting of this variable affects the behavior of replication filtering options with regard to case sensitivity. For more information, see Section 19.2.5, “How Servers Evaluate Replication Filtering Rules”.

    禁止使用与服务器初始化时使用的设置不同的 lower_case_table_names 设置来启动服务器。此限制是必要的,因为各种数据字典表字段使用的排序规则是由服务器初始化时定义的设置决定的,而使用不同的设置重新启动服务器会导致标识符的排序和比较方式出现不一致。It is prohibited to start the server with a lower_case_table_names setting that is different from the setting used when the server was initialized. The restriction is necessary because collations used by various data dictionary table fields are determined by the setting defined when the server is initialized, and restarting the server with a different setting would introduce inconsistencies with respect to how identifiers are ordered and compared.

    因此,有必要在初始化服务器之前将lower_case_table_names配置为所需的设置。在大多数情况下,这需要在首次启动 MySQL 服务器之前,在 MySQL 选项文件中配置lower_case_table_names。然而,对于在 Debian 和 Ubuntu 上使用 APT 安装的情况,服务器会为你初始化,因此没有机会事先在选项文件中配置该设置。因此,你必须在使用 APT 安装 MySQL 之前使用debconf-set-selection工具来启用lower_case_table_names。为此,请在使用 APT 安装 MySQL 之前运行此命令:It is therefore necessary to configure lower_case_table_names to the desired setting before initializing the server. In most cases, this requires configuring lower_case_table_names in a MySQL option file before starting the MySQL server for the first time. For APT installations on Debian and Ubuntu, however, the server is initialized for you, and there is no opportunity to configure the setting in an option file beforehand. You must therefore use the debconf-set-selection utility prior to installing MySQL using APT to enable lower_case_table_names. To do so, run this command before installing MySQL using APT:

    $> sudo debconf-set-selections <<< "mysql-server mysql-server/lowercase-table-names select Enabled"
    
  • mandatory_roles

    命令行格式Command-Line Format --mandatory-roles=value
    系统变量System Variable mandatory_roles
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value empty stringempty string

    服务器应视为必需的角色。实际上,这些角色会自动授予每个用户,尽管设置 mandatory_roles 并不会实际更改任何用户账户,并且授予的角色在 mysql.role_edges 系统表中不可见。Roles the server should treat as mandatory. In effect, these roles are automatically granted to every user, although setting mandatory_roles does not actually change any user accounts, and the granted roles are not visible in the mysql.role_edges system table.

    变量值是以逗号分隔的角色名称列表。例如:The variable value is a comma-separated list of role names. Example:

    SET PERSIST mandatory_roles = '`role1`@`%`,`role2`,role3,role4@localhost';
    

    设置mandatory_roles的运行时值需要ROLE_ADMIN权限,此外还需要通常设置全局系统变量运行时值时所需的SYSTEM_VARIABLES_ADMIN权限(或已弃用的SUPER权限)。Setting the runtime value of mandatory_roles requires the ROLE_ADMIN privilege, in addition to the SYSTEM_VARIABLES_ADMIN privilege (or the deprecated SUPER privilege) normally required to set a global system variable runtime value.

    角色名称由用户部分和主机部分组成,格式为user_name@host_name。如果省略主机部分,默认值为%。有关更多信息,请参见第 8.2.5 节,“指定角色名称”。Role names consist of a user part and host part in user_name@host_name format. The host part, if omitted, defaults to %. For additional information, see Section 8.2.5, “Specifying Role Names”.

    mandatory_roles的值是一个字符串,因此如果用户名和主机名被引用,必须以允许在引用字符串中使用的方式编写。The mandatory_roles value is a string, so user names and host names, if quoted, must be written in a fashion permitted for quoting within quoted strings.

    在 mandatory_roles 的值中命名的角色,不能使用 REVOKE 撤销,也不能使用 DROP ROLE 或 DROP USER 删除。Roles named in the value of mandatory_roles cannot be revoked with REVOKE or dropped with DROP ROLE or DROP USER.

    为了防止会话默认成为系统会话,具有 SYSTEM_USER 权限的角色不能列在 mandatory_roles 系统变量的值中:To prevent sessions from being made system sessions by default, a role that has the SYSTEM_USER privilege cannot be listed in the value of the mandatory_roles system variable:

    强制角色,如显式授予的角色,在激活之前不会生效(参见 激活角色)。在登录时,如果启用了 activate_all_roles_on_login 系统变量,则所有授予的角色都会被激活;否则,或者对于设置为默认角色的角色,在其他情况下生效。在运行时,SET ROLE 会激活角色。Mandatory roles, like explicitly granted roles, do not take effect until activated (see Activating Roles). At login time, role activation occurs for all granted roles if the activate_all_roles_on_login system variable is enabled; otherwise, or for roles that are set as default roles otherwise. At runtime, SET ROLE activates roles.

    在分配给 mandatory_roles 时不存在的角色,但以后创建的角色,可能需要特殊处理才能被视为强制角色。有关详细信息,请参阅 定义强制角色。Roles that do not exist when assigned to mandatory_roles but are created later may require special treatment to be considered mandatory. For details, see Defining Mandatory Roles.

    SHOW GRANTS 根据 第 15.7.7.22 节,“SHOW GRANTS 语句” 中描述的规则显示强制角色。SHOW GRANTS displays mandatory roles according to the rules described in Section 15.7.7.22, “SHOW GRANTS Statement”.

  • max_allowed_packet

    命令行格式Command-Line Format --max-allowed-packet=#
    系统变量System Variable max_allowed_packet
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 67108864
    最小值Minimum Value 1024
    最大值Maximum Value 1073741824
    单位Unit 字节bytes
    块大小Block Size 1024

    单个数据包或任意生成/中间字符串,或通过mysql_stmt_send_long_data() C API 函数发送的任意参数的最大大小。默认值为 64MB。The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function. The default is 64MB.

    数据包消息缓冲区初始化为 net_buffer_length 字节,但在需要时可以增长到 max_allowed_packet 字节。这个值默认较小,以捕获大的(可能不正确的)数据包。The packet message buffer is initialized to net_buffer_length bytes, but can grow up to max_allowed_packet bytes when needed. This value by default is small, to catch large (possibly incorrect) packets.

    如果您使用大型BLOB列或长字符串,则必须增加此值。它应该与您想要使用的最大BLOB大小相同。max_allowed_packet的协议限制为 1GB。该值应为 1024 的倍数;非倍数将被向下取整到最近的倍数。You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use. The protocol limit for max_allowed_packet is 1GB. The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple.

    当您通过更改max_allowed_packet变量的值来更改消息缓冲区大小时,如果客户端程序允许,您也应更改客户端的缓冲区大小。客户端库内置的默认max_allowed_packet值是 1GB,但各个客户端程序可能会覆盖此值。例如,mysql和mysqldump的默认值分别为 16MB 和 24MB。它们也允许您在命令行或选项文件中设置max_allowed_packet来更改客户端的值。When you change the message buffer size by changing the value of the max_allowed_packet variable, you should also change the buffer size on the client side if your client program permits it. The default max_allowed_packet value built in to the client library is 1GB, but individual client programs might override this. For example, mysql and mysqldump have defaults of 16MB and 24MB, respectively. They also enable you to change the client-side value by setting max_allowed_packet on the command line or in an option file.

    该变量的会话值是只读的。客户端可以接收的字节数最多与会话值相同。然而,服务器不会向客户端发送超过当前全局 max_allowed_packet 值的字节数。(如果全局值在客户端连接后被更改,则全局值可能小于会话值。)The session value of this variable is read only. The client can receive up to as many bytes as the session value. However, the server does not send to the client more bytes than the current global max_allowed_packet value. (The global value could be less than the session value if the global value is changed after the client connects.)

  • max_connect_errors

    命令行格式Command-Line Format --max-connect-errors=#
    系统变量System Variable max_connect_errors
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 100
    最小值Minimum Value 1
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    当来自某个主机的连续 max_connect_errors 次连接请求在未成功连接的情况下被中断时,服务器将阻止该主机进行进一步的连接。如果某个主机的连接在前一次连接被中断后,在少于 max_connect_errors 次尝试内成功建立,则该主机的错误计数将清零。要解除对被阻止主机的阻止,请刷新主机缓存;参见 刷新主机缓存。After max_connect_errors successive connection requests from a host are interrupted without a successful connection, the server blocks that host from further connections. If a connection from a host is established successfully within fewer than max_connect_errors attempts after a previous connection was interrupted, the error count for the host is cleared to zero. To unblock blocked hosts, flush the host cache; see Flushing the Host Cache.

  • max_connections

    命令行格式Command-Line Format --max-connections=#
    系统变量System Variable max_connections
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 151
    最小值Minimum Value 1
    最大值Maximum Value 100000

    允许的最大同时客户端连接数。最大有效值是 open_files_limit - 810 的有效值与实际设置的 max_connections 值中的较小者。The maximum permitted number of simultaneous client connections. The maximum effective value is the lesser of the effective value of open_files_limit - 810, and the value actually set for max_connections.

    更多信息,请参见 第 7.1.12.1 节,“连接接口”。For more information, see Section 7.1.12.1, “Connection Interfaces”.

  • max_delayed_threads

    命令行格式Command-Line Format --max-delayed-threads=#
    已弃用Deprecated 是Yes
    系统变量System Variable max_delayed_threads
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 20
    最小值Minimum Value 0
    最大值Maximum Value 16384

    这个系统变量已被弃用(因为不支持 DELAYED 插入),并可能在将来的 MySQL 版本中被移除。This system variable is deprecated (because DELAYED inserts are not supported) and subject to removal in a future MySQL release.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • max_digest_length

    命令行格式Command-Line Format --max-digest-length=#
    系统变量System Variable max_digest_length
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1024
    最小值Minimum Value 0
    最大值Maximum Value 1048576
    单位Unit 字节bytes

    每个会话为计算标准化语句摘要保留的最大内存字节数。一旦在摘要计算过程中使用了该数量的空间,就会发生截断:不会再收集解析语句的更多标记,也不会将其计入摘要值。仅在该字节数之后解析标记内容不同的语句,会产生相同的标准化语句摘要,并在比较或为摘要统计汇总时被视为相同。The maximum number of bytes of memory reserved per session for computation of normalized statement digests. Once that amount of space is used during digest computation, truncation occurs: no further tokens from a parsed statement are collected or figure into its digest value. Statements that differ only after that many bytes of parsed tokens produce the same normalized statement digest and are considered identical if compared or if aggregated for digest statistics.

    用于计算归一化语句摘要的长度是归一化语句摘要长度与语句摘要长度之和。由于语句摘要的长度始终为 64,这等同于 LENGTH (STATEMENT_DIGEST_TEXT(statement) ) + 64。这意味着,当 max_digest_length 的值为 1024(默认值)时,归一化 SQL 语句在截断发生之前的最大长度实际上为 960 字节。The length used for calculating a normalized statement digest is the sum of the length of the normalized statement digest and the length of the statement digest. Since the length of the statement digest is always 64, this is equivalent to LENGTH (STATEMENT_DIGEST_TEXT(statement) ) + 64. This means that, when the value of max_digest_length is 1024 (the default), the maximum length for a normalized SQL statement before truncation occurs is in effect 960 bytes.

    Warning

    将 max_digest_length 设置为零会禁用摘要生成,这也会禁用需要摘要的服务器功能,例如 MySQL 企业防火墙。Setting max_digest_length to zero disables digest production, which also disables server functionality that requires digests, such as MySQL Enterprise Firewall.

    降低 max_digest_length 值可以减少内存使用,但如果语句仅在末尾不同,则更多语句的摘要值将无法区分。增加该值可以区分更长的语句,但会增加内存使用,尤其是对于涉及大量并发会话的工作负载(服务器为每个会话分配 max_digest_length 字节)。Decreasing the max_digest_length value reduces memory use but causes the digest value of more statements to become indistinguishable if they differ only at the end. Increasing the value permits longer statements to be distinguished but increases memory use, particularly for workloads that involve large numbers of simultaneous sessions (the server allocates max_digest_length bytes per session).

    解析器使用该系统变量作为它计算的规范化语句摘要的最大长度限制。如果性能架构跟踪语句摘要,它会复制摘要值,并使用 performance_schema_max_digest_length 系统变量作为它存储的摘要的最大长度限制。因此,如果 performance_schema_max_digest_length 小于 max_digest_length,存储在性能架构中的摘要值将相对于原始摘要值被截断。The parser uses this system variable as a limit on the maximum length of normalized statement digests that it computes. The Performance Schema, if it tracks statement digests, makes a copy of the digest value, using the performance_schema_max_digest_length. system variable as a limit on the maximum length of digests that it stores. Consequently, if performance_schema_max_digest_length is less than max_digest_length, digest values stored in the Performance Schema are truncated relative to the original digest values.

    有关语句摘要的更多信息,请参见 第 29.10 节,“Performance Schema 语句摘要与采样”。For more information about statement digesting, see Section 29.10, “Performance Schema Statement Digests and Sampling”.

  • max_error_count

    命令行格式Command-Line Format --max-error-count=#
    系统变量System Variable max_error_count
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 1024
    最小值Minimum Value 0
    最大值Maximum Value 65535

    SHOW ERRORS 和 SHOW WARNINGS 语句用于存储显示的最大错误、警告和信息消息数量。这与诊断区中的条件区数量相同,因此也就是可被 GET DIAGNOSTICS 检查的条件数量。The maximum number of error, warning, and information messages to be stored for display by the SHOW ERRORS and SHOW WARNINGS statements. This is the same as the number of condition areas in the diagnostics area, and thus the number of conditions that can be inspected by GET DIAGNOSTICS.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • max_execution_time

    命令行格式Command-Line Format --max-execution-time=#
    系统变量System Variable max_execution_time
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 4294967295
    单位Unit 毫秒milliseconds

    SELECT语句的执行超时时间,单位为毫秒。如果值为 0,则不启用超时。The execution timeout for SELECT statements, in milliseconds. If the value is 0, timeouts are not enabled.

    max_execution_time 的应用如下:max_execution_time applies as follows:

    • 全局 max_execution_time 值为新连接的会话值提供默认值。会话值适用于会话内执行的 SELECT 操作,如果没有包含 MAX_EXECUTION_TIME(N) 优化器提示,或者 N 为 0 的情况。The global max_execution_time value provides the default for the session value for new connections. The session value applies to SELECT executions executed within the session that include no MAX_EXECUTION_TIME(N) optimizer hint or for which N is 0.

    • max_execution_time 适用于只读的 SELECT 语句。非只读语句是指调用会以副作用修改数据的存储函数的语句。max_execution_time applies to read-only SELECT statements. Statements that are not read only are those that invoke a stored function that modifies data as a side effect.

    • max_execution_time 在存储程序中的 SELECT 语句中被忽略。max_execution_time is ignored for SELECT statements in stored programs.

  • max_heap_table_size

    命令行格式Command-Line Format --max-heap-table-size=#
    系统变量System Variable max_heap_table_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 16777216
    最小值Minimum Value 16384
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709550592
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294966272
    单位Unit 字节bytes
    块大小Block Size 1024

    此变量设置用户创建的 MEMORY 表允许增长的最大大小。该变量的值用于计算 MEMORY 表的 MAX_ROWS 值。This variable sets the maximum size to which user-created MEMORY tables are permitted to grow. The value of the variable is used to calculate MEMORY table MAX_ROWS values.

    设置此变量对任何现有的 MEMORY 表没有影响,除非使用 CREATE TABLE 语句重新创建表,或使用 ALTER TABLE 或 TRUNCATE TABLE 修改表。服务器重启也会将现有 MEMORY 表的最大大小设置为全局 max_heap_table_size 值。Setting this variable has no effect on any existing MEMORY table, unless the table is re-created with a statement such as CREATE TABLE or altered with ALTER TABLE or TRUNCATE TABLE. A server restart also sets the maximum size of existing MEMORY tables to the global max_heap_table_size value.

    该变量还与 tmp_table_size 一起使用,以限制内部内存表的大小。请参阅 第 10.4.4 节,“MySQL 中的内部临时表使用”。This variable is also used in conjunction with tmp_table_size to limit the size of internal in-memory tables. See Section 10.4.4, “Internal Temporary Table Use in MySQL”.

    max_heap_table_size 不会被复制。有关更多信息,请参阅 第 19.5.1.21 节,“复制与 MEMORY 表” 和 第 19.5.1.39 节,“复制与变量”。max_heap_table_size is not replicated. See Section 19.5.1.21, “Replication and MEMORY Tables”, and Section 19.5.1.39, “Replication and Variables”, for more information.

  • max_insert_delayed_threads

    已弃用Deprecated 是Yes
    系统变量System Variable max_insert_delayed_threads
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 20
    最大值Maximum Value 16384

    此变量是 max_delayed_threads 的同义词。像 max_delayed_threads 一样,它已被弃用(因为不支持 DELAYED 插入)并可能在未来的 MySQL 版本中被移除。This variable is a synonym for max_delayed_threads. Like max_delayed_threads, it is deprecated (because DELAYED inserts are not supported) and subject to removal in a future MySQL release.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • max_join_size

    命令行格式Command-Line Format --max-join-size=#
    系统变量System Variable max_join_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 18446744073709551615
    最小值Minimum Value 1
    最大值Maximum Value 18446744073709551615

    这表示联接访问基础表的最大行数限制。如果服务器的估算表明必须从基础表中读取的行数超过 max_join_size,则该语句将被拒绝并返回错误。This represents a limit on the maximum number of row accesses in base tables made by a join. If the server's estimate indicates that a greater number of rows than max_join_size must be read from the base tables, the statement is rejected with an error.

    将此变量设置为非 DEFAULT 的值会将 sql_big_selects 的值重置为 0。如果您再次设置 sql_big_selects 值,则会忽略 max_join_size 变量。Setting this variable to a value other than DEFAULT resets the value of sql_big_selects to 0. If you set the sql_big_selects value again, the max_join_size variable is ignored.

  • max_length_for_sort_data

    命令行格式Command-Line Format --max-length-for-sort-data=#
    已弃用Deprecated 是Yes
    系统变量System Variable max_length_for_sort_data
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 4096
    最小值Minimum Value 4
    最大值Maximum Value 8388608
    单位Unit 字节bytes

    这个变量已被弃用,并且在 MySQL 8.4 中没有效果。This variable is deprecated, and has no effect in MySQL 8.4.

  • max_points_in_geometry

    命令行格式Command-Line Format --max-points-in-geometry=#
    系统变量System Variable max_points_in_geometry
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 65536
    最小值Minimum Value 3
    最大值Maximum Value 1048576

    作为 ST_Buffer_Strategy() 函数 points_per_circle 参数的最大值。The maximum value of the points_per_circle argument to the ST_Buffer_Strategy() function.

  • max_prepared_stmt_count

    命令行格式Command-Line Format --max-prepared-stmt-count=#
    系统变量System Variable max_prepared_stmt_count
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 16382
    最小值Minimum Value 0
    最大值Maximum Value 4194304

    该变量限制了服务器中已准备语句的总数。它可以用于可能出现基于通过准备大量语句而耗尽服务器内存的拒绝服务攻击的环境。如果值设置低于当前已准备语句的数量,现有语句不会受到影响,可以继续使用,但在当前语句数量降到限制以下之前,不能准备新的语句。将值设置为 0 会禁用已准备语句。This variable limits the total number of prepared statements in the server. It can be used in environments where there is the potential for denial-of-service attacks based on running the server out of memory by preparing huge numbers of statements. If the value is set lower than the current number of prepared statements, existing statements are not affected and can be used, but no new statements can be prepared until the current number drops below the limit. Setting the value to 0 disables prepared statements.

  • max_seeks_for_key

    命令行格式Command-Line Format --max-seeks-for-key=#
    系统变量System Variable max_seeks_for_key
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值(Windows)Default Value (Windows) 4294967295
    默认值(其他,64 位平台)Default Value (Other, 64-bit platforms) 18446744073709551615
    默认值(其他,32 位平台)Default Value (Other, 32-bit platforms) 4294967295
    最小值Minimum Value 1
    最大值(Windows)Maximum Value (Windows) 4294967295
    最大值(其他,64 位平台)Maximum Value (Other, 64-bit platforms) 18446744073709551615
    最大值(其他,32 位平台)Maximum Value (Other, 32-bit platforms) 4294967295

    在根据键查找行时,限制假定的最大查找次数。MySQL 优化器假设在通过扫描索引在表中搜索匹配行时,不需要超过此数量的键查找次数,无论索引的实际基数如何(参见 第 15.7.7.23 节,“SHOW INDEX 语句”)。通过将其设置为较低值(例如 100),可以强制 MySQL 优先使用索引而不是表扫描。Limit the assumed maximum number of seeks when looking up rows based on a key. The MySQL optimizer assumes that no more than this number of key seeks are required when searching for matching rows in a table by scanning an index, regardless of the actual cardinality of the index (see Section 15.7.7.23, “SHOW INDEX Statement”). By setting this to a low value (say, 100), you can force MySQL to prefer indexes instead of table scans.

  • max_sort_length

    命令行格式Command-Line Format --max-sort-length=#
    系统变量System Variable max_sort_length
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 1024
    最小值Minimum Value 4
    最大值Maximum Value 8388608
    单位Unit 字节bytes

    在对使用 PAD SPACE 校对规则的字符串值进行排序时使用的字节数。服务器只使用这些值的前 max_sort_length 字节,其余部分将被忽略。因此,那些在前 max_sort_length 字节之后才不同的值,在 GROUP BY、ORDER BY 和 DISTINCT 操作中将被视为相等。(这种行为不同于以前版本的 MySQL,以前的版本中,该设置会应用于用于比较的所有值。)The number of bytes to use when sorting string values which use PAD SPACE collations. The server uses only the first max_sort_length bytes of any such value and ignores the rest. Consequently, such values that differ only after the first max_sort_length bytes compare as equal for GROUP BY, ORDER BY, and DISTINCT operations. (This behavior differs from previous versions of MySQL, where this setting was applied to all values used in comparisons.)

    增加 max_sort_length 的值可能也需要增加 sort_buffer_size 的值。详情请参见 第 10.2.1.16 节,“ORDER BY 优化”Increasing the value of max_sort_length may require increasing the value of sort_buffer_size as well. For details, see Section 10.2.1.16, “ORDER BY Optimization”

  • max_sp_recursion_depth

    命令行格式Command-Line Format --max-sp-recursion-depth[=#]
    系统变量System Variable max_sp_recursion_depth
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 255

    任何给定存储过程可以递归调用的次数。此选项的默认值为 0,表示完全禁用存储过程中的递归。最大值为 255。The number of times that any given stored procedure may be called recursively. The default value for this option is 0, which completely disables recursion in stored procedures. The maximum value is 255.

    存储过程递归会增加线程堆栈空间的需求。如果增加 max_sp_recursion_depth 的值,可能需要通过在服务器启动时增加 thread_stack 的值来增加线程堆栈大小。Stored procedure recursion increases the demand on thread stack space. If you increase the value of max_sp_recursion_depth, it may be necessary to increase thread stack size by increasing the value of thread_stack at server startup.

  • max_user_connections

    命令行格式Command-Line Format --max-user-connections=#
    系统变量System Variable max_user_connections
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    允许任何给定 MySQL 用户帐户的最大同时连接数。值为 0(默认值)表示“无限制。”The maximum number of simultaneous connections permitted to any given MySQL user account. A value of 0 (the default) means “no limit.”

    此变量具有可以在服务器启动时或运行时设置的全局值。它还具有只读会话值,该值指示适用于与当前会话关联的帐户的有效同时连接限制。会话值初始化如下:This variable has a global value that can be set at server startup or runtime. It also has a read-only session value that indicates the effective simultaneous-connection limit that applies to the account associated with the current session. The session value is initialized as follows:

    帐户资源限制是使用 CREATE USER 或 ALTER USER 语句指定的。参见 第 8.2.21 节,“设置帐户资源限制”。Account resource limits are specified using the CREATE USER or ALTER USER statement. See Section 8.2.21, “Setting Account Resource Limits”.

  • max_write_lock_count

    命令行格式Command-Line Format --max-write-lock-count=#
    系统变量System Variable max_write_lock_count
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值(Windows)Default Value (Windows) 4294967295
    默认值(其他,64 位平台)Default Value (Other, 64-bit platforms) 18446744073709551615
    默认值(其他,32 位平台)Default Value (Other, 32-bit platforms) 4294967295
    最小值Minimum Value 1
    最大值(Windows)Maximum Value (Windows) 4294967295
    最大值(其他,64 位平台)Maximum Value (Other, 64-bit platforms) 18446744073709551615
    最大值(其他,32 位平台)Maximum Value (Other, 32-bit platforms) 4294967295

    在经过这么多写锁之后,允许在其间处理一些待处理的读锁请求。写锁请求优先于读锁请求。但是,如果 max_write_lock_count 设置为较低的值(例如 10),那么如果读锁请求已经被忽略以让 10 个写锁请求优先执行,则读锁请求可能会被优先处理。通常这种情况不会发生,因为 max_write_lock_count 默认值非常大。After this many write locks, permit some pending read lock requests to be processed in between. Write lock requests have higher priority than read lock requests. However, if max_write_lock_count is set to some low value (say, 10), read lock requests may be preferred over pending write lock requests if the read lock requests have already been passed over in favor of 10 write lock requests. Normally this behavior does not occur because max_write_lock_count by default has a very large value.

  • mecab_rc_file

    命令行格式Command-Line Format --mecab-rc-file=file_name--mecab-rc-file=file_name
    系统变量System Variable mecab_rc_file
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name

    mecab_rc_file 选项用于设置 MeCab 全文解析器时使用。The mecab_rc_file option is used when setting up the MeCab full-text parser.

    mecab_rc_file 选项定义了 mecabrc 配置文件的路径,该文件是 MeCab 的配置文件。此选项为只读,仅能在启动时设置。初始化 MeCab 时需要 mecabrc 配置文件。The mecab_rc_file option defines the path to the mecabrc configuration file, which is the configuration file for MeCab. The option is read-only and can only be set at startup. The mecabrc configuration file is required to initialize MeCab.

    有关 MeCab 全文解析器的信息,请参见 第 14.9.9 节,“MeCab 全文解析器插件”。For information about the MeCab full-text parser, see Section 14.9.9, “MeCab Full-Text Parser Plugin”.

    有关可以在 MeCab mecabrc 配置文件中指定的选项的信息,请参阅 MeCab 文档,该文档位于 Google Developers 网站上。For information about options that can be specified in the MeCab mecabrc configuration file, refer to the MeCab Documentation on the Google Developers site.

  • min_examined_row_limit

    命令行格式Command-Line Format --min-examined-row-limit=#
    系统变量System Variable min_examined_row_limit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    检查的行数少于此数量的查询不会记录到慢查询日志中。Queries that examine fewer than this number of rows are not logged to the slow query log.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • myisam_data_pointer_size

    命令行格式Command-Line Format --myisam-data-pointer-size=#
    系统变量System Variable myisam_data_pointer_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 6
    最小值Minimum Value 2
    最大值Maximum Value 7
    单位Unit 字节bytes

    默认指针大小(以字节为单位),在未指定 MAX_ROWS 选项时,将由 CREATE TABLE 用于 MyISAM 表。此变量不能小于 2 或大于 7。默认值为 6。参见 B.3.2.10 节,“表已满”。The default pointer size in bytes, to be used by CREATE TABLE for MyISAM tables when no MAX_ROWS option is specified. This variable cannot be less than 2 or larger than 7. The default value is 6. See Section B.3.2.10, “The table is full”.

  • myisam_max_sort_file_size

    命令行格式Command-Line Format --myisam-max-sort-file-size=#
    系统变量System Variable myisam_max_sort_file_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值(Windows)Default Value (Windows) 2146435072
    默认值(其他,64 位平台)Default Value (Other, 64-bit platforms) 9223372036853727232
    默认值(其他,32 位平台)Default Value (Other, 32-bit platforms) 2147483648
    最小值Minimum Value 0
    最大值(Windows)Maximum Value (Windows) 2146435072
    最大值(其他,64 位平台)Maximum Value (Other, 64-bit platforms) 9223372036853727232
    最大值(其他,32 位平台)Maximum Value (Other, 32-bit platforms) 2147483648
    单位Unit 字节bytes

    MySQL 在重新创建 MyISAM 索引时(在 REPAIR TABLE、ALTER TABLE 或 LOAD DATA 时)允许使用的临时文件的最大大小。如果文件大小超过此值,则索引将改用键缓存创建,这会更慢。该值以字节为单位。The maximum size of the temporary file that MySQL is permitted to use while re-creating a MyISAM index (during REPAIR TABLE, ALTER TABLE, or LOAD DATA). If the file size would be larger than this value, the index is created using the key cache instead, which is slower. The value is given in bytes.

    如果 MyISAM 索引文件超过此大小并且磁盘空间充足,增加该值可能会提升性能。所需空间必须在包含原索引文件目录的文件系统中可用。If MyISAM index files exceed this size and disk space is available, increasing the value may help performance. The space must be available in the file system containing the directory where the original index file is located.

  • myisam_mmap_size

    命令行格式Command-Line Format --myisam-mmap-size=#
    系统变量System Variable myisam_mmap_size
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值(64 位平台)Default Value (64-bit platforms) 18446744073709551615
    默认值(32 位平台)Default Value (32-bit platforms) 4294967295
    最小值Minimum Value 7
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295
    单位Unit 字节bytes

    用于内存映射压缩的 MyISAM 文件的最大内存量。如果使用了许多压缩的 MyISAM 表,可以降低该值以减少内存交换问题的可能性。The maximum amount of memory to use for memory mapping compressed MyISAM files. If many compressed MyISAM tables are used, the value can be decreased to reduce the likelihood of memory-swapping problems.

  • myisam_recover_options

    命令行格式Command-Line Format --myisam-recover-options[=list]
    系统变量System Variable myisam_recover_options
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value OFFOFF
    有效值Valid Values

    OFFOFF

    DEFAULTDEFAULT

    BACKUPBACKUP

    FORCEFORCE

    QUICKQUICK

    设置 MyISAM 存储引擎的恢复模式。变量值可以是 OFF、DEFAULT、BACKUP、FORCE 或 QUICK 的任意组合。如果指定多个值,请用逗号分隔。在服务器启动时指定变量而不赋值,相当于指定 DEFAULT;明确指定值为 "" 会禁用恢复(与值为 OFF 相同)。如果启用恢复,每次 mysqld 打开 MyISAM 表时,会检查该表是否标记为崩溃或未正确关闭。(最后一个选项仅在禁用外部锁时有效。)如果存在这种情况,mysqld 会对表进行检查。如果表损坏,mysqld 会尝试修复它。Set the MyISAM storage engine recovery mode. The variable value is any combination of the values of OFF, DEFAULT, BACKUP, FORCE, or QUICK. If you specify multiple values, separate them by commas. Specifying the variable with no value at server startup is the same as specifying DEFAULT, and specifying with an explicit value of "" disables recovery (same as a value of OFF). If recovery is enabled, each time mysqld opens a MyISAM table, it checks whether the table is marked as crashed or was not closed properly. (The last option works only if you are running with external locking disabled.) If this is the case, mysqld runs a check on the table. If the table was corrupted, mysqld attempts to repair it.

    以下选项会影响修复的工作方式。The following options affect how the repair works.

    选项Option 说明Description
    OFFOFF 不进行恢复。No recovery.
    DEFAULTDEFAULT 在没有备份、强制或快速检查的情况下恢复。Recovery without backup, forcing, or quick checking.
    BACKUPBACKUP 如果在恢复过程中数据文件被更改,请将 tbl_name.MYD 文件备份为 tbl_name-datetime.BAK。If the data file was changed during recovery, save a backup of the tbl_name.MYD file as tbl_name-datetime.BAK.
    FORCEFORCE 即使我们会从 .MYD 文件中丢失多于一行,也要运行恢复。Run recovery even if we would lose more than one row from the .MYD file.
    QUICKQUICK 如果没有任何删除块,请不要勾选表格中的行。Do not check the rows in the table if there are not any delete blocks.

    在服务器自动修复表之前,它会在错误日志中写一条关于修复的记录。如果你希望在大多数问题下无需用户干预就能恢复,你应该使用选项BACKUP,FORCE。这会强制修复表,即使某些行将被删除,但它会保留旧的数据文件作为备份,以便你之后可以检查发生了什么。Before the server automatically repairs a table, it writes a note about the repair to the error log. If you want to be able to recover from most problems without user intervention, you should use the options BACKUP,FORCE. This forces a repair of a table even if some rows would be deleted, but it keeps the old data file as a backup so that you can later examine what happened.

    请参见第 18.2.1 节,“MyISAM 启动选项”。See Section 18.2.1, “MyISAM Startup Options”.

  • myisam_sort_buffer_size

    命令行格式Command-Line Format --myisam-sort-buffer-size=#
    系统变量System Variable myisam_sort_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8388608
    最小值Minimum Value 4096
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295
    单位Unit 字节bytes

    在使用 REPAIR TABLE 修复表或者使用 CREATE INDEX 或 ALTER TABLE 创建索引时,对 MyISAM 索引排序时分配的缓冲区大小。The size of the buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE or when creating indexes with CREATE INDEX or ALTER TABLE.

  • myisam_stats_method

    命令行格式Command-Line Format --myisam-stats-method=name
    系统变量System Variable myisam_stats_method
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value nulls_unequal
    有效值Valid Values

    nulls_unequal

    nulls_equalnulls_equal

    nulls_ignorednulls_ignored

    当服务器收集关于 MyISAM 表的索引值分布的统计信息时,如何处理 NULL 值。该变量有三个可能的值:nulls_equal、nulls_unequal 和 nulls_ignored。对于 nulls_equal,所有 NULL 索引值被视为相等,并形成一个值组,其大小等于 NULL 值的数量。对于 nulls_unequal,NULL 值被视为不相等,每个 NULL 形成一个大小为 1 的独立值组。对于 nulls_ignored,NULL 值被忽略。How the server treats NULL values when collecting statistics about the distribution of index values for MyISAM tables. This variable has three possible values, nulls_equal, nulls_unequal, and nulls_ignored. For nulls_equal, all NULL index values are considered equal and form a single value group that has a size equal to the number of NULL values. For nulls_unequal, NULL values are considered unequal, and each NULL forms a distinct value group of size 1. For nulls_ignored, NULL values are ignored.

    用于生成表统计信息的方法会影响优化器选择查询执行索引的方式,如第 10.3.8 节,“InnoDB 和 MyISAM 索引统计收集”所述。The method that is used for generating table statistics influences how the optimizer chooses indexes for query execution, as described in Section 10.3.8, “InnoDB and MyISAM Index Statistics Collection”.

  • myisam_use_mmap

    命令行格式Command-Line Format --myisam-use-mmap[={OFF|ON}]--myisam-use-mmap[={OFF|ON}]
    系统变量System Variable myisam_use_mmap
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    用于读取和写入 MyISAM 表时使用内存映射。Use memory mapping for reading and writing MyISAM tables.

  • mysql_native_password_proxy_users

    命令行格式Command-Line Format --mysql-native-password-proxy-users[={OFF|ON}]--mysql-native-password-proxy-users[={OFF|ON}]
    已弃用Deprecated 是Yes
    系统变量System Variable mysql_native_password_proxy_users
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此变量控制内置的 mysql_native_password 身份验证插件(已弃用)是否支持代理用户。除非启用了 check_proxy_users 系统变量和 mysql_native_password 插件,否则此变量不会生效。有关用户代理的信息,请参见 第 8.2.19 节,“代理用户”。This variable controls whether the mysql_native_password built-in authentication plugin (deprecated) supports proxy users. It has no effect unless the check_proxy_users system variable and the mysql_native_password plugin are enabled. For information about user proxying, see Section 8.2.19, “Proxy Users”.

  • named_pipe

    命令行格式Command-Line Format --named-pipe[={OFF|ON}]--named-pipe[={OFF|ON}]
    系统变量System Variable named_pipenamed_pipe
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific 窗口Windows
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    (仅限 Windows。)指示服务器是否支持通过命名管道进行连接。(Windows only.) Indicates whether the server supports connections over named pipes.

  • named_pipe_full_access_group

    命令行格式Command-Line Format --named-pipe-full-access-group=value
    系统变量System Variable named_pipe_full_access_group
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific 窗口Windows
    类型Type 字符串String
    默认值Default Value empty stringempty string
    有效值Valid Values

    empty stringempty string

    valid Windows local group namevalid Windows local group name

    *everyone*

    (仅限 Windows。)当启用 named_pipe 系统变量以支持命名管道连接时,MySQL 服务器创建的命名管道授予客户端的访问控制设置为成功通信所需的最低权限。一些 MySQL 客户端软件可以在无需任何额外配置的情况下打开命名管道连接;然而,其他客户端软件可能仍然需要完全访问权限才能打开命名管道连接。(Windows only.) The access control granted to clients on the named pipe created by the MySQL server is set to the minimum necessary for successful communication when the named_pipe system variable is enabled to support named-pipe connections. Some MySQL client software can open named pipe connections without any additional configuration; however, other client software may still require full access to open a named pipe connection.

    此变量设置 Windows 本地组的名称,其成员被 MySQL 服务器授予使用命名管道客户端的足够访问权限。默认值是空字符串,这意味着没有 Windows 用户被授予对命名管道的完全访问权限。This variable sets the name of a Windows local group whose members are granted sufficient access by the MySQL server to use named-pipe clients. The default value is an empty string, which means that no Windows user is granted full access to the named pipe.

    可以在 Windows 中创建一个新的本地组名(例如,mysql_access_client_users),然后在确实需要访问时用它替代默认值。在这种情况下,应将组成员限制在尽可能少的用户,并在用户的客户端软件升级后将其从组中移除。非组成员尝试使用受影响的命名管道客户端连接 MySQL 时,将被拒绝访问,直到 Windows 管理员将该用户添加到组中。新添加的用户必须注销并重新登录才能加入该组(Windows 的要求)。A new Windows local group name (for example, mysql_access_client_users) can be created in Windows and then used to replace the default value when access is absolutely necessary. In this case, limit the membership of the group to as few users as possible, removing users from the group when their client software is upgraded. A non-member of the group who attempts to open a connection to MySQL with the affected named-pipe client is denied access until a Windows administrator adds the user to the group. Newly added users must log out and log in again to join the group (required by Windows).

    将值设置为 '*everyone*' 提供了一种与语言无关的方式来引用 Windows 上的 Everyone 组。Everyone 组默认情况下是不安全的。Setting the value to '*everyone*' provides a language-independent way of referring to the Everyone group on Windows. The Everyone group is not secure by default.

  • net_buffer_length

    命令行格式Command-Line Format --net-buffer-length=#
    系统变量System Variable net_buffer_length
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 16384
    最小值Minimum Value 1024
    最大值Maximum Value 1048576
    单位Unit 字节bytes
    块大小Block Size 1024

    每个客户端线程都与一个连接缓冲区和结果缓冲区相关联。两者的初始大小由 net_buffer_length 决定,但会根据需要动态扩大到 max_allowed_packet 字节。每条 SQL 语句执行后,结果缓冲区会缩小到 net_buffer_length。Each client thread is associated with a connection buffer and result buffer. Both begin with a size given by net_buffer_length but are dynamically enlarged up to max_allowed_packet bytes as needed. The result buffer shrinks to net_buffer_length after each SQL statement.

    这个变量通常不应更改,但如果您的内存非常有限,您可以将其设置为客户端发送语句的预期长度。如果语句超过此长度,连接缓冲区会自动增大。net_buffer_length 可以设置的最大值是 1MB。This variable should not normally be changed, but if you have very little memory, you can set it to the expected length of statements sent by clients. If statements exceed this length, the connection buffer is automatically enlarged. The maximum value to which net_buffer_length can be set is 1MB.

    此变量的会话值为只读。The session value of this variable is read only.

  • net_read_timeout

    命令行格式Command-Line Format --net-read-timeout=#
    系统变量System Variable net_read_timeout
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 30
    最小值Minimum Value 1
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    在中止读取之前等待连接提供更多数据的秒数。当服务器从客户端读取数据时,net_read_timeout 是控制何时中止的超时时间。当服务器向客户端写入数据时,net_write_timeout 是控制何时中止的超时时间。另请参阅 replica_net_timeout。The number of seconds to wait for more data from a connection before aborting the read. When the server is reading from the client, net_read_timeout is the timeout value controlling when to abort. When the server is writing to the client, net_write_timeout is the timeout value controlling when to abort. See also replica_net_timeout.

  • net_retry_count

    命令行格式Command-Line Format --net-retry-count=#
    系统变量System Variable net_retry_count
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 10
    最小值Minimum Value 1
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295

    如果对通信端口的读或写操作被中断,在放弃之前要重试这么多次。在 FreeBSD 上,这个值应该设置得相当高,因为内部中断会发送到所有线程。If a read or write on a communication port is interrupted, retry this many times before giving up. This value should be set quite high on FreeBSD because internal interrupts are sent to all threads.

  • net_write_timeout

    命令行格式Command-Line Format --net-write-timeout=#
    系统变量System Variable net_write_timeout
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 60
    最小值Minimum Value 1
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    在中止写入之前等待块写入连接的秒数。另请参见 net_read_timeout。The number of seconds to wait for a block to be written to a connection before aborting the write. See also net_read_timeout.

  • ngram_token_size

    命令行格式Command-Line Format --ngram-token-size=#
    系统变量System Variable ngram_token_size
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 2
    最小值Minimum Value 1
    最大值Maximum Value 10

    定义 n-gram 全文解析器的 n-gram 令牌大小。ngram_token_size 选项是只读的,只能在启动时修改。默认值为 2(二元组)。最大值为 10。Defines the n-gram token size for the n-gram full-text parser. The ngram_token_size option is read-only and can only be modified at startup. The default value is 2 (bigram). The maximum value is 10.

    有关如何配置此变量的更多信息,请参见 第 14.9.8 节,“ngram 全文解析器”。For more information about how to configure this variable, see Section 14.9.8, “ngram Full-Text Parser”.

  • offline_mode

    命令行格式Command-Line Format --offline-mode[={OFF|ON}]
    系统变量System Variable offline_mode
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    在离线模式下,MySQL 实例会断开客户用户的连接,除非他们拥有相关权限,并且不允许他们发起新的连接。被拒绝访问的客户将收到 ER_SERVER_OFFLINE_MODE 错误。In offline mode, the MySQL instance disconnects client users unless they have relevant privileges, and does not allow them to initiate new connections. Clients that are refused access receive an ER_SERVER_OFFLINE_MODE error.

    要将服务器设置为离线模式,请将系统变量 offline_mode 的值从 OFF 改为 ON。要恢复正常操作,请将 offline_mode 的值从 ON 改回 OFF。要控制离线模式,管理员账号必须具有 SYSTEM_VARIABLES_ADMIN 权限和 CONNECTION_ADMIN 权限(或已弃用的 SUPER 权限,该权限涵盖这两个权限)。需要 CONNECTION_ADMIN,以防止意外锁定。To put a server in offline mode, change the value of the offline_mode system variable from OFF to ON. To resume normal operations, change offline_mode from ON to OFF. To control offline mode, an administrator account must have the SYSTEM_VARIABLES_ADMIN privilege and the CONNECTION_ADMIN privilege (or the deprecated SUPER privilege, which covers both these privileges). CONNECTION_ADMIN is required, to prevent accidental lockout.

    离线模式具有以下特点:Offline mode has these characteristics:

    • 没有 CONNECTION_ADMIN 权限(或已废弃的 SUPER 权限)的已连接客户端用户将在下一次请求时被断开连接,并显示相应的错误。断开连接包括终止正在运行的语句和释放锁。此类客户端也无法发起新的连接,并会收到相应的错误。Connected client users who do not have the CONNECTION_ADMIN privilege (or the deprecated SUPER privilege) are disconnected on the next request, with an appropriate error. Disconnection includes terminating running statements and releasing locks. Such clients also cannot initiate new connections, and receive an appropriate error.

    • 具有 CONNECTION_ADMIN 或 SUPER 权限的已连接客户端用户不会被断开连接,并且可以发起新的连接以管理服务器。Connected client users who have the CONNECTION_ADMIN or SUPER privilege are not disconnected, and can initiate new connections to manage the server.

    • If the user that puts a server in offline mode does not have the SYSTEM_USER privilege, connected client users who have the SYSTEM_USER privilege are also not disconnected. However, these users cannot initiate new connections to the server while it is in offline mode, unless they have the CONNECTION_ADMIN或者SUPER privilege as well. It is only their existing connection that cannot be terminated, because the SYSTEM_USER privilege is required to kill a session or statement that is executing with the SYSTEM_USER特权。If the user that puts a server in offline mode does not have the SYSTEM_USER privilege, connected client users who have the SYSTEM_USER privilege are also not disconnected. However, these users cannot initiate new connections to the server while it is in offline mode, unless they have the CONNECTION_ADMIN or SUPER privilege as well. It is only their existing connection that cannot be terminated, because the SYSTEM_USER privilege is required to kill a session or statement that is executing with the SYSTEM_USER privilege.

    • 允许复制线程继续向服务器应用数据。Replication threads are permitted to keep applying data to the server.

  • old_alter_table

    命令行格式Command-Line Format --old-alter-table[={OFF|ON}]--old-alter-table[={OFF|ON}]
    系统变量System Variable old_alter_table
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    当启用此变量时,服务器不会使用优化的方法来处理 ALTER TABLE 操作。它会回退到使用临时表的方式,先复制数据,然后将临时表重命名为原表,这与 MySQL 5.0 及更早版本的做法相同。有关 ALTER TABLE 操作的更多信息,请参见 第 15.1.9 节,“ALTER TABLE 语句”。When this variable is enabled, the server does not use the optimized method of processing an ALTER TABLE operation. It reverts to using a temporary table, copying over the data, and then renaming the temporary table to the original, as used by MySQL 5.0 and earlier. For more information on the operation of ALTER TABLE, see Section 15.1.9, “ALTER TABLE Statement”.

    ALTER TABLE ... DROP PARTITION 在 old_alter_table=ON 设置下,会重建分区表并尝试将被删除分区的数据移动到具有兼容 PARTITION ... VALUES 定义的其他分区中。无法移动到其他分区的数据将被删除。在早期版本中,ALTER TABLE ... DROP PARTITION 在 old_alter_table=ON 设置下,会删除存储在该分区的数据并删除该分区。ALTER TABLE ... DROP PARTITION with old_alter_table=ON rebuilds the partitioned table and attempts to move data from the dropped partition to another partition with a compatible PARTITION ... VALUES definition. Data that cannot be moved to another partition is deleted. In earlier releases, ALTER TABLE ... DROP PARTITION with old_alter_table=ON deletes data stored in the partition and drops the partition.

  • open_files_limit

    命令行格式Command-Line Format --open-files-limit=#
    系统变量System Variable open_files_limit
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 5000, with possible adjustment5000, with possible adjustment
    最小值Minimum Value 0
    最大值Maximum Value platform dependentplatform dependent

    操作系统提供给 mysqld 的文件描述符数量:The number of file descriptors available to mysqld from the operating system:

    • 在启动时,mysqld 使用 setrlimit() 预留描述符,使用通过直接设置此变量或通过 --open-files-limit 选项设置给 mysqld_safe 的值。如果 mysqld 产生错误 Too many open files,请尝试增加 open_files_limit 的值。在内部,该变量的最大值是无符号整数的最大值,但实际最大值取决于平台。At startup, mysqld reserves descriptors with setrlimit(), using the value requested at by setting this variable directly or by using the --open-files-limit option to mysqld_safe. If mysqld produces the error Too many open files, try increasing the open_files_limit value. Internally, the maximum value for this variable is the maximum unsigned integer value, but the actual maximum is platform dependent.

    • 在运行时,open_files_limit 的值表示操作系统实际允许 mysqld 使用的文件描述符数量,这可能与启动时请求的值不同。如果在启动期间请求的文件描述符数量无法分配,mysqld 会向错误日志写入一条警告。At runtime, the value of open_files_limit indicates the number of file descriptors actually permitted to mysqld by the operating system, which might differ from the value requested at startup. If the number of file descriptors requested during startup cannot be allocated, mysqld writes a warning to the error log.

    有效的 open_files_limit 值基于系统启动时指定的值(如果有的话)以及 max_connections 和 table_open_cache 的值,使用以下公式计算:The effective open_files_limit value is based on the value specified at system startup (if any) and the values of max_connections and table_open_cache, using these formulas:

    • 10 + max_connections + (table_open_cache * 2)。使用这些变量的默认值会得到 8161。10 + max_connections + (table_open_cache * 2). Using the defaults for these variables yields 8161.

      仅在 Windows 上,将 2048(C 运行时库文件描述符最大值)添加到该数字。这总计为 10209,同样使用指示的系统变量的默认值。On Windows only, 2048 (the value of the C Run-Time Library file descriptor maximum) is added to this number. This totals 10209, again using the default values for the indicated system variables.

    • max_connections * 5max_connections * 5

    • 操作系统限制。The operating system limit.

    服务器尝试使用这些值中的最大值来获取文件描述符的数量,并将其限制为最大无符号整数值。如果无法获取这么多描述符,服务器将尝试获取系统允许的尽可能多的数量。The server attempts to obtain the number of file descriptors using the maximum of those values, capped to the maximum unsigned integer value. If that many descriptors cannot be obtained, the server attempts to obtain as many as the system permits.

    在 MySQL 无法更改打开文件数量的系统上,有效值为 0。The effective value is 0 on systems where MySQL cannot change the number of open files.

    在 Unix 系统中,该值不能设置得高于 ulimit -n 命令显示的值。在使用 systemd 的 Linux 系统中,该值不能设置得高于 LimitNOFILE(如果未设置 LimitNOFILE,则为 DefaultLimitNOFILE);否则,在 Linux 系统中,open_files_limit 的值不能超过 ulimit -n。On Unix, the value cannot be set greater than the value displayed by the ulimit -n command. On Linux systems using systemd, the value cannot be set greater than LimitNOFILE (this is DefaultLimitNOFILE, if LimitNOFILE is not set); otherwise, on Linux, the value of open_files_limit cannot exceed ulimit -n.

  • optimizer_prune_level

    命令行格式Command-Line Format --optimizer-prune-level=#
    系统变量System Variable optimizer_prune_level
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 1
    最小值Minimum Value 0
    最大值Maximum Value 1

    控制在查询优化期间应用的启发式方法,以从优化器搜索空间中修剪不太有前景的部分计划。值为 0 时禁用启发式方法,使优化器执行全面搜索。值为 1 时,优化器会根据中间计划检索的行数来修剪计划。Controls the heuristics applied during query optimization to prune less-promising partial plans from the optimizer search space. A value of 0 disables heuristics so that the optimizer performs an exhaustive search. A value of 1 causes the optimizer to prune plans based on the number of rows retrieved by intermediate plans.

  • optimizer_search_depth

    命令行格式Command-Line Format --optimizer-search-depth=#
    系统变量System Variable optimizer_search_depth
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 62
    最小值Minimum Value 0
    最大值Maximum Value 62

    查询优化器执行的最大搜索深度。大于查询中关系数量的值会生成更好的查询计划,但生成查询执行计划所需的时间更长。小于查询中关系数量的值会更快返回执行计划,但生成的计划可能远非最优。如果设置为 0,系统会自动选择一个合理的值。The maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to generate an execution plan for a query. Values smaller than the number of relations in a query return an execution plan quicker, but the resulting plan may be far from being optimal. If set to 0, the system automatically picks a reasonable value.

  • optimizer_switch

    命令行格式Command-Line Format --optimizer-switch=value
    系统变量System Variable optimizer_switch
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 设置Set
    有效值Valid Values

    batched_key_access={on|off}batched_key_access={on|off}

    block_nested_loop={on|off}block_nested_loop={on|off}

    condition_fanout_filter={on|off}condition_fanout_filter={on|off}

    derived_condition_pushdown={on|off}derived_condition_pushdown={on|off}

    derived_merge={on|off}derived_merge={on|off}

    duplicateweedout={on|off}duplicateweedout={on|off}

    engine_condition_pushdown={on|off}engine_condition_pushdown={on|off}

    firstmatch={on|off}firstmatch={on|off}

    hash_join={on|off}hash_join={on|off}

    index_condition_pushdown={on|off}index_condition_pushdown={on|off}

    index_merge={on|off}index_merge={on|off}

    index_merge_intersection={on|off}index_merge_intersection={on|off}

    index_merge_sort_union={on|off}index_merge_sort_union={on|off}

    index_merge_union={on|off}index_merge_union={on|off}

    loosescan={on|off}loosescan={on|off}

    materialization={on|off}materialization={on|off}

    mrr={on|off}mrr={on|off}

    mrr_cost_based={on|off}mrr_cost_based={on|off}

    prefer_ordering_index={on|off}prefer_ordering_index={on|off}

    semijoin={on|off}semijoin={on|off}

    skip_scan={on|off}skip_scan={on|off}

    subquery_materialization_cost_based={on|off}subquery_materialization_cost_based={on|off}

    subquery_to_derived={on|off}subquery_to_derived={on|off}

    use_index_extensions={on|off}use_index_extensions={on|off}

    use_invisible_indexes={on|off}use_invisible_indexes={on|off}

    optimizer_switch 系统变量用于控制优化器的行为。该变量的值是一组标志,每个标志的值为 on 或 off,用于指示相应的优化器行为是启用还是禁用。该变量具有全局值和会话值,并且可以在运行时更改。全局默认值可以在服务器启动时设置。The optimizer_switch system variable enables control over optimizer behavior. The value of this variable is a set of flags, each of which has a value of on or off to indicate whether the corresponding optimizer behavior is enabled or disabled. This variable has global and session values and can be changed at runtime. The global default can be set at server startup.

    要查看当前的优化器标志集,请选择变量值:To see the current set of optimizer flags, select the variable value:

    mysql> SELECT @@optimizer_switch\G
    *************************** 1. row ***************************
    @@optimizer_switch: index_merge=on,index_merge_union=on,
                        index_merge_sort_union=on,index_merge_intersection=on,
                        engine_condition_pushdown=on,index_condition_pushdown=on,
                        mrr=on,mrr_cost_based=on,block_nested_loop=on,
                        batched_key_access=off,materialization=on,semijoin=on,
                        loosescan=on,firstmatch=on,duplicateweedout=on,
                        subquery_materialization_cost_based=on,
                        use_index_extensions=on,condition_fanout_filter=on,
                        derived_merge=on,use_invisible_indexes=off,skip_scan=on,
                        hash_join=on,subquery_to_derived=off,
                        prefer_ordering_index=on,hypergraph_optimizer=off,
                        derived_condition_pushdown=on,hash_set_operations=on
    1 row in set (0.00 sec)
    

    有关此变量的语法以及其控制的优化器行为的更多信息,请参见 第 10.9.2 节,“可切换的优化”。For more information about the syntax of this variable and the optimizer behaviors that it controls, see Section 10.9.2, “Switchable Optimizations”.

  • optimizer_trace

    命令行格式Command-Line Format --optimizer-trace=value
    系统变量System Variable optimizer_trace
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    此变量用于控制优化器跟踪。详情请参见 第 10.15 节,“优化器跟踪”。This variable controls optimizer tracing. For details, see Section 10.15, “Tracing the Optimizer”.

  • optimizer_trace_features

    命令行格式Command-Line Format --optimizer-trace-features=value
    系统变量System Variable optimizer_trace_features
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    此变量用于启用或禁用选定的优化器跟踪功能。有关详细信息,请参见 第 10.15 节,“跟踪优化器”。This variable enables or disables selected optimizer tracing features. For details, see Section 10.15, “Tracing the Optimizer”.

  • optimizer_trace_limit

    命令行格式Command-Line Format --optimizer-trace-limit=#
    系统变量System Variable optimizer_trace_limit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1
    最小值Minimum Value 0
    最大值Maximum Value 2147483647

    要显示的优化器跟踪的最大数量。有关详细信息,请参见 第 10.15 节,“跟踪优化器”。The maximum number of optimizer traces to display. For details, see Section 10.15, “Tracing the Optimizer”.

  • optimizer_trace_max_mem_size

    命令行格式Command-Line Format --optimizer-trace-max-mem-size=#
    系统变量System Variable optimizer_trace_max_mem_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 1048576
    最小值Minimum Value 0
    最大值Maximum Value 4294967295
    单位Unit 字节bytes

    存储的优化器跟踪的最大累计大小。详情请参见 第 10.15 节,“跟踪优化器”。The maximum cumulative size of stored optimizer traces. For details, see Section 10.15, “Tracing the Optimizer”.

  • optimizer_trace_offset

    命令行格式Command-Line Format --optimizer-trace-offset=#
    系统变量System Variable optimizer_trace_offset
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value -1
    最小值Minimum Value -2147483647
    最大值Maximum Value 2147483647

    要显示的优化器跟踪的偏移量。详情请参见 第 10.15 节,“跟踪优化器”。The offset of optimizer traces to display. For details, see Section 10.15, “Tracing the Optimizer”.

  • performance_schema_xxx

    Performance Schema 系统变量列在 第 29.15 节,“Performance Schema 系统变量” 中。可使用这些变量来配置 Performance Schema 的操作。Performance Schema system variables are listed in Section 29.15, “Performance Schema System Variables”. These variables may be used to configure Performance Schema operation.

  • parser_max_mem_size

    命令行格式Command-Line Format --parser-max-mem-size=#
    系统变量System Variable parser_max_mem_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值(64 位平台)Default Value (64-bit platforms) 18446744073709551615
    默认值(32 位平台)Default Value (32-bit platforms) 4294967295
    最小值Minimum Value 10000000
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295
    单位Unit 字节bytes

    解析器可用的最大内存量。默认值对可用内存没有限制。可以降低该值以防止解析长或复杂的 SQL 语句时发生内存不足的情况。The maximum amount of memory available to the parser. The default value places no limit on memory available. The value can be reduced to protect against out-of-memory situations caused by parsing long or complex SQL statements.

  • partial_revokes

    命令行格式Command-Line Format --partial-revokes[={OFF|ON}]
    系统变量System Variable partial_revokes
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value

    OFF(如果部分撤销不存在)OFF (if partial revokes do not exist)

    ON(如果部分撤销存在)ON (if partial revokes exist)

    启用此变量可以部分撤销权限。具体来说,对于在全局级别拥有权限的用户,partial_revokes 允许撤销特定模式的权限,同时保留其他模式的权限。例如,拥有全局 UPDATE 权限的用户,可以被限制在 mysql 系统模式上行使该权限。(或者换句话说,该用户可以在除 mysql 模式之外的所有模式上行使 UPDATE 权限。)从这个意义上讲,用户的全局 UPDATE 权限被部分撤销。Enabling this variable makes it possible to revoke privileges partially. Specifically, for users who have privileges at the global level, partial_revokes enables privileges for specific schemas to be revoked while leaving the privileges in place for other schemas. For example, a user who has the global UPDATE privilege can be restricted from exercising this privilege on the mysql system schema. (Or, stated another way, the user is enabled to exercise the UPDATE privilege on all schemas except the mysql schema.) In this sense, the user's global UPDATE privilege is partially revoked.

    一旦启用,partial_revokes 如果任何账户存在权限限制,则无法禁用。如果存在这样的账户,禁用 partial_revokes 将失败:Once enabled, partial_revokes cannot be disabled if any account has privilege restrictions. If any such account exists, disabling partial_revokes fails:

    要在这种情况下禁用 partial_revokes,首先需要修改每个拥有部分撤销权限的账户,要么重新授予权限,要么删除该账户。To disable partial_revokes in this case, first modify each account that has partially revoked privileges, either by re-granting the privileges or by removing the account.

    Note

    在权限分配中,启用 partial_revokes 会导致 MySQL 将模式名称中未转义的 _ 和 % SQL 通配符字符解释为字面字符,就像它们已经被转义为 \_ 和 \% 一样。由于这会改变 MySQL 对权限的解释,因此在可能启用 partial_revokes 的安装环境中,建议在权限分配中避免使用未转义的通配符字符。In privilege assignments, enabling partial_revokes causes MySQL to interpret occurrences of unescaped _ and % SQL wildcard characters in schema names as literal characters, just as if they had been escaped as \_ and \%. Because this changes how MySQL interprets privileges, it may be advisable to avoid unescaped wildcard characters in privilege assignments for installations where partial_revokes may be enabled.

    此外,在权限授予中使用 _ 和 % 作为通配符字符已被弃用,您应该预期在未来的 MySQL 版本中对它们的支持将被移除。In addition, use of _ and % as wildcard characters in grants is deprecated, and you should expect support for them to be removed in a future version of MySQL.

    有关更多信息,包括如何删除部分撤销权限的说明,请参见 第 8.2.12 节,“使用部分撤销限制权限”。For more information, including instructions for removing partial revokes, see Section 8.2.12, “Privilege Restriction Using Partial Revokes”.

  • password_history

    命令行格式Command-Line Format --password-history=#
    系统变量System Variable password_history
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    此变量定义了基于所需最少密码更改次数的全局策略,用于控制以前密码的重用。对于之前使用过的账户密码,此变量指示在该密码可以被重用之前,账户密码必须进行的后续更改次数。如果值为 0(默认值),则没有基于密码更改次数的重用限制。This variable defines the global policy for controlling reuse of previous passwords based on required minimum number of password changes. For an account password used previously, this variable indicates the number of subsequent account password changes that must occur before the password can be reused. If the value is 0 (the default), there is no reuse restriction based on number of password changes.

    对该变量的更改将立即应用于所有使用 PASSWORD HISTORY DEFAULT 选项定义的账户。Changes to this variable apply immediately to all accounts defined with the PASSWORD HISTORY DEFAULT option.

    可以使用 CREATE USER 和 ALTER USER 语句的 PASSWORD HISTORY 选项,为单个账户按需覆盖全局更改次数密码重用策略。请参见 第 8.2.15 节,“密码管理”。The global number-of-changes password reuse policy can be overridden as desired for individual accounts using the PASSWORD HISTORY option of the CREATE USER and ALTER USER statements. See Section 8.2.15, “Password Management”.

  • password_require_current

    命令行格式Command-Line Format --password-require-current[={OFF|ON}]
    系统变量System Variable password_require_current
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此变量定义了全局策略,用于控制更改账户密码时是否必须指定要替换的当前密码。This variable defines the global policy for controlling whether attempts to change an account password must specify the current password to be replaced.

    对该变量的更改会立即应用于所有使用 PASSWORD REQUIRE CURRENT DEFAULT 选项定义的账户。Changes to this variable apply immediately to all accounts defined with the PASSWORD REQUIRE CURRENT DEFAULT option.

    可以使用 PASSWORD REQUIRE 和 ALTER USER 语句中的 CREATE USER 选项,为单个账户按需覆盖全局必须验证策略。参见 第 8.2.15 节,“密码管理”。The global verification-required policy can be overridden as desired for individual accounts using the PASSWORD REQUIRE option of the CREATE USER and ALTER USER statements. See Section 8.2.15, “Password Management”.

  • password_reuse_interval

    命令行格式Command-Line Format --password-reuse-interval=#
    系统变量System Variable password_reuse_interval
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 4294967295
    单位Unit 天days

    此变量定义了基于时间间隔控制以前密码重用的全局策略。对于之前使用过的账户密码,此变量指示在密码可以再次使用之前必须经过的天数。如果值为 0(默认值),则不会基于经过时间限制重用。This variable defines the global policy for controlling reuse of previous passwords based on time elapsed. For an account password used previously, this variable indicates the number of days that must pass before the password can be reused. If the value is 0 (the default), there is no reuse restriction based on time elapsed.

    对该变量的更改会立即应用于所有使用 PASSWORD REUSE INTERVAL DEFAULT 选项定义的账户。Changes to this variable apply immediately to all accounts defined with the PASSWORD REUSE INTERVAL DEFAULT option.

    全局的基于时间间隔的密码重用策略可以根据需要针对单个账户进行覆盖,使用 PASSWORD REUSE INTERVAL 选项,该选项可以在 CREATE USER 和 ALTER USER 语句中使用。请参见 第 8.2.15 节,“密码管理”。The global time-elapsed password reuse policy can be overridden as desired for individual accounts using the PASSWORD REUSE INTERVAL option of the CREATE USER and ALTER USER statements. See Section 8.2.15, “Password Management”.

  • persisted_globals_load

    命令行格式Command-Line Format --persisted-globals-load[={OFF|ON}]
    系统变量System Variable persisted_globals_load
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    是否从数据目录中的 mysqld-auto.cnf 文件加载持久化配置设置。服务器通常在启动时处理此文件,且在处理所有其他选项文件之后(见 第 6.2.2.2 节,“使用选项文件”)。禁用 persisted_globals_load 会导致服务器启动过程跳过 mysqld-auto.cnf。Whether to load persisted configuration settings from the mysqld-auto.cnf file in the data directory. The server normally processes this file at startup after all other option files (see Section 6.2.2.2, “Using Option Files”). Disabling persisted_globals_load causes the server startup sequence to skip mysqld-auto.cnf.

    要修改 mysqld-auto.cnf 的内容,请使用 SET PERSIST、SET PERSIST_ONLY 和 RESET PERSIST 语句。请参阅 第 7.1.9.3 节,“持久化系统变量”。To modify the contents of mysqld-auto.cnf, use the SET PERSIST, SET PERSIST_ONLY, and RESET PERSIST statements. See Section 7.1.9.3, “Persisted System Variables”.

  • persist_only_admin_x509_subject

    命令行格式Command-Line Format --persist-only-admin-x509-subject=string
    系统变量System Variable persist_only_admin_x509_subject
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value empty stringempty string

    SET PERSIST 和 SET PERSIST_ONLY 允许将系统变量持久化到数据目录中的 mysqld-auto.cnf 选项文件中(参见 第 15.7.6.1 节,“SET 变量赋值语法”)。持久化系统变量可以在运行时进行配置更改,从而影响后续服务器重启,这对于无需直接访问 MySQL 服务器主机选项文件的远程管理非常方便。然而,一些系统变量是不可持久化的,或者只能在某些限制条件下持久化。SET PERSIST and SET PERSIST_ONLY enable system variables to be persisted to the mysqld-auto.cnf option file in the data directory (see Section 15.7.6.1, “SET Syntax for Variable Assignment”). Persisting system variables enables runtime configuration changes that affect subsequent server restarts, which is convenient for remote administration not requiring direct access to MySQL server host option files. However, some system variables are nonpersistible or can be persisted only under certain restrictive conditions.

    persist_only_admin_x509_subject 系统变量指定用户必须具备的 SSL 证书 X.509 Subject 值,才能持久化那些受持久化限制的系统变量。默认值为空字符串,这会禁用 Subject 检查,因此任何用户都无法持久化受持久化限制的系统变量。The persist_only_admin_x509_subject system variable specifies the SSL certificate X.509 Subject value that users must have to be able to persist system variables that are persist-restricted. The default value is the empty string, which disables the Subject check so that persist-restricted system variables cannot be persisted by any user.

    如果 persist_only_admin_x509_subject 非空,则使用加密连接并提供具有指定 Subject 值的 SSL 证书连接到服务器的用户可以使用 SET PERSIST_ONLY 来持久化受限制持久化的系统变量。有关受限制持久化系统变量的信息以及配置 MySQL 以启用 persist_only_admin_x509_subject 的说明,请参见 第 7.1.9.4 节,“不可持久化和受限制持久化系统变量”。If persist_only_admin_x509_subject is nonempty, users who connect to the server using an encrypted connection and supply an SSL certificate with the designated Subject value then can use SET PERSIST_ONLY to persist persist-restricted system variables. For information about persist-restricted system variables and instructions for configuring MySQL to enable persist_only_admin_x509_subject, see Section 7.1.9.4, “Nonpersistible and Persist-Restricted System Variables”.

  • persist_sensitive_variables_in_plaintext

    命令行格式Command-Line Format --persist_sensitive_variables_in_plaintext[={OFF|ON}]
    系统变量System Variable persist_sensitive_variables_in_plaintext
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    persist_sensitive_variables_in_plaintext 控制服务器是否允许以未加密的格式存储敏感系统变量的值,如果在使用 SET PERSIST 设置系统变量的值时,keyring 组件支持不可用。它还控制如果加密值无法解密,服务器是否能够启动。请注意,keyring 插件不支持对敏感系统变量的安全存储;必须在 MySQL 服务器实例上启用 keyring 组件(参见 第 8.4.4 节,“MySQL Keyring”)以支持安全存储。persist_sensitive_variables_in_plaintext controls whether the server is permitted to store the values of sensitive system variables in an unencrypted format, if keyring component support is not available at the time when SET PERSIST is used to set the value of the system variable. It also controls whether or not the server can start if the encrypted values cannot be decrypted. Note that keyring plugins do not support secure storage of sensitive system variables; a keyring component (see Section 8.4.4, “The MySQL Keyring”) must be enabled on the MySQL Server instance to support secure storage.

    默认设置,ON,如果存在 keyring 组件支持,则会加密数值;如果没有,则以未加密状态保存(并发出警告)。下次设置任何持久化的系统变量时,如果此时提供了 keyring 支持,服务器会加密任何未加密的敏感系统变量值。ON 设置还允许服务器在无法解密加密的系统变量值时启动,此时会发出警告,并使用系统变量的默认值。在这种情况下,除非能解密,否则这些值无法更改。The default setting, ON, encrypts the values if keyring component support is available, and persists them unencrypted (with a warning) if it is not. The next time any persisted system variable is set, if keyring support is available at that time, the server encrypts the values of any unencrypted sensitive system variables. The ON setting also allows the server to start if encrypted system variable values cannot be decrypted, in which case a warning is issued and the default values for the system variables are used. In that situation, their values cannot be changed until they can be decrypted.

    最安全的设置,OFF,表示如果没有 keyring 组件支持,敏感系统变量值不能被持久化。OFF 设置也意味着如果无法解密加密的系统变量值,服务器将无法启动。The most secure setting, OFF, means sensitive system variable values cannot be persisted if keyring component support is unavailable. The OFF setting also means the server does not start if encrypted system variable values cannot be decrypted.

    更多信息,请参见 持久化敏感系统变量。For more information, see Persisting Sensitive System Variables.

  • pid_file

    命令行格式Command-Line Format --pid-file=file_name--pid-file=file_name
    系统变量System Variable pid_file
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name

    服务器写入其进程 ID 的文件的路径名。除非提供了绝对路径名来指定其他目录,否则服务器会在数据目录中创建该文件。如果您指定此变量,则必须指定一个值。如果您未指定此变量,MySQL 将使用默认值 host_name.pid,其中 host_name 是主机名称。The path name of the file in which the server writes its process ID. The server creates the file in the data directory unless an absolute path name is given to specify a different directory. If you specify this variable, you must specify a value. If you do not specify this variable, MySQL uses a default value of host_name.pid, where host_name is the name of the host machine.

    进程 ID 文件被其他程序(例如 mysqld_safe)用来确定服务器的进程 ID。在 Windows 上,该变量还会影响默认错误日志文件名。请参阅 第 7.4.2 节,“错误日志”。The process ID file is used by other programs such as mysqld_safe to determine the server's process ID. On Windows, this variable also affects the default error log file name. See Section 7.4.2, “The Error Log”.

  • plugin_dir

    命令行格式Command-Line Format --plugin-dir=dir_name--plugin-dir=dir_name
    系统变量System Variable plugin_dir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value BASEDIR/lib/plugin

    插件目录的路径名称。The path name of the plugin directory.

    如果插件目录可以被服务器写入,用户可能通过 SELECT ... INTO DUMPFILE 将可执行代码写入目录中的文件。可以通过将 plugin_dir 设置为服务器只读,或将 secure_file_priv 设置为 SELECT 可以安全写入的目录来防止此类操作。If the plugin directory is writable by the server, it may be possible for a user to write executable code to a file in the directory using SELECT ... INTO DUMPFILE. This can be prevented by making plugin_dir read only to the server or by setting secure_file_priv to a directory where SELECT writes can be made safely.

  • port

    命令行格式Command-Line Format --port=port_num--port=port_num
    系统变量System Variable portport
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 3306
    最小值Minimum Value 0
    最大值Maximum Value 65535

    服务器用于监听 TCP/IP 连接的端口号。可以使用 --port 选项设置此变量。The number of the port on which the server listens for TCP/IP connections. This variable can be set with the --port option.

  • preload_buffer_size

    命令行格式Command-Line Format --preload-buffer-size=#
    系统变量System Variable preload_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 32768
    最小值Minimum Value 1024
    最大值Maximum Value 1073741824
    单位Unit 字节bytes

    预加载索引时分配的缓冲区大小。The size of the buffer that is allocated when preloading indexes.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • print_identified_with_as_hex

    命令行格式Command-Line Format --print-identified-with-as-hex[={OFF|ON}]
    系统变量System Variable print_identified_with_as_hex
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    在SHOW CREATE USER输出的IDENTIFIED WITH子句中显示的密码哈希值可能包含不可打印字符,这些字符会对终端显示及其他环境产生不良影响。启用print_identified_with_as_hex会使SHOW CREATE USER将此类哈希值显示为十六进制字符串,而不是常规字符串字面值。不包含不可打印字符的哈希值即使启用此变量,仍会显示为常规字符串字面值。Password hash values displayed in the IDENTIFIED WITH clause of output from SHOW CREATE USER may contain unprintable characters that have adverse effects on terminal displays and in other environments. Enabling print_identified_with_as_hex causes SHOW CREATE USER to display such hash values as hexadecimal strings rather than as regular string literals. Hash values that do not contain unprintable characters still display as regular string literals, even with this variable enabled.

  • profiling

    如果设置为 0 或 OFF(默认值),语句分析将被禁用。如果设置为 1 或 ON,语句分析将启用,并且 SHOW PROFILE 和 SHOW PROFILES 语句可以访问分析信息。参见 第 15.7.7.33 节,“SHOW PROFILES 语句”。If set to 0 or OFF (the default), statement profiling is disabled. If set to 1 or ON, statement profiling is enabled and the SHOW PROFILE and SHOW PROFILES statements provide access to profiling information. See Section 15.7.7.33, “SHOW PROFILES Statement”.

    此变量已被弃用;预计将在未来的 MySQL 版本中移除。This variable is deprecated; expect it to be removed in a future MySQL release.

  • profiling_history_size

    如果启用了profiling,要为其维护分析信息的语句数量。默认值为 15。最大值为 100。将值设置为 0 将有效地禁用分析。参见第 15.7.7.33 节,“SHOW PROFILES 语句”。The number of statements for which to maintain profiling information if profiling is enabled. The default value is 15. The maximum value is 100. Setting the value to 0 effectively disables profiling. See Section 15.7.7.33, “SHOW PROFILES Statement”.

    此变量已被弃用;预计将在未来的 MySQL 版本中移除。This variable is deprecated; expect it to be removed in a future MySQL release.

  • protocol_compression_algorithms

    命令行格式Command-Line Format --protocol-compression-algorithms=value
    系统变量System Variable protocol_compression_algorithms
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 设置Set
    默认值Default Value zlib,zstd,uncompressed
    有效值Valid Values

    zlib

    zstd

    uncompresseduncompressed

    服务器允许用于传入连接的压缩算法。这包括客户端程序的连接以及参与源/副本复制或组复制的服务器的连接。压缩不适用于 FEDERATED 表的连接。The compression algorithms that the server permits for incoming connections. These include connections by client programs and by servers participating in source/replica replication or Group Replication. Compression does not apply to connections for FEDERATED tables.

    protocol_compression_algorithms 不控制 X 协议的连接压缩。有关其工作方式的信息,请参阅 第 22.5.5 节,“X 插件的连接压缩”。protocol_compression_algorithms does not control connection compression for X Protocol. See Section 22.5.5, “Connection Compression with X Plugin” for information on how this operates.

    该变量的值是一个或多个以逗号分隔的压缩算法名称列表,顺序不限,可从以下项目中选择(不区分大小写):The variable value is a list of one or more comma-separated compression algorithm names, in any order, chosen from the following items (not case-sensitive):

    • zlib:允许使用 zlib 压缩算法的连接。zlib: Permit connections that use the zlib compression algorithm.

    • zstd:允许使用 zstd 压缩算法的连接。zstd: Permit connections that use the zstd compression algorithm.

    • uncompressed:允许未压缩的连接。如果该算法名称未包含在 protocol_compression_algorithms 的值中,服务器将不允许未压缩连接。它只允许使用值中指定的其他算法的压缩连接,并且不会回退到未压缩连接。uncompressed: Permit uncompressed connections. If this algorithm name is not included in the protocol_compression_algorithms value, the server does not permit uncompressed connections. It permits only compressed connections that use whichever other algorithms are specified in the value, and there is no fallback to uncompressed connections.

    zlib,zstd,uncompressed 的默认值表示服务器允许所有压缩算法。The default value of zlib,zstd,uncompressed indicates that the server permits all compression algorithms.

    更多信息,请参阅 第 6.2.8 节,“连接压缩控制”。For more information, see Section 6.2.8, “Connection Compression Control”.

  • protocol_version

    系统变量System Variable protocol_version
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 10
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    MySQL 服务器使用的客户端/服务器协议版本。The version of the client/server protocol used by the MySQL server.

  • proxy_user

    系统变量System Variable proxy_user
    范围Scope 会议Session
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    如果当前客户端是另一个用户的代理,则此变量是代理用户帐户名。否则,此变量为 NULL。参见 第 8.2.19 节,“代理用户”。If the current client is a proxy for another user, this variable is the proxy user account name. Otherwise, this variable is NULL. See Section 8.2.19, “Proxy Users”.

  • pseudo_replica_mode pseudo_replica_mode

    系统变量System Variable pseudo_replica_modepseudo_replica_mode
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean

    pseudo_replica_mode 供服务器内部使用。它有助于正确处理那些比当前处理它们的服务器版本更新或更旧的服务器上发起的事务。mysqlbinlog 在执行任何 SQL 语句之前,将 pseudo_replica_mode 的值设置为 true。pseudo_replica_mode is for internal server use. It assists with the correct handling of transactions that originated on older or newer servers than the server currently processing them. mysqlbinlog sets the value of pseudo_replica_mode to true before executing any SQL statements.

    设置 pseudo_replica_mode 的会话值是一项受限操作。会话用户必须拥有 REPLICATION_APPLIER 权限(参见 第 19.3.3 节,“复制权限检查”),或拥有足够权限以设置受限会话变量(参见 第 7.1.9.1 节,“系统变量权限”)。但是,请注意,该变量并非用于用户设置;它由复制基础设施自动设置。Setting the session value of pseudo_replica_mode is a restricted operation. The session user must have either the REPLICATION_APPLIER privilege (see Section 19.3.3, “Replication Privilege Checks”), or privileges sufficient to set restricted session variables (see Section 7.1.9.1, “System Variable Privileges”). However, note that the variable is not intended for users to set; it is set automatically by the replication infrastructure.

    pseudo_replica_mode 对已准备的 XA 事务的处理具有以下影响,这些事务可以附加到或从处理会话中分离(默认情况下为发出 XA START 的会话):pseudo_replica_mode has the following effects on the handling of prepared XA transactions, which can be attached to or detached from the handling session (by default, the session that issues XA START):

    • 如果为真,并且处理会话已经执行了内部使用的 BINLOG 语句,当事务的第一部分直到 XA PREPARE 完成时,XA 事务会自动从会话中分离,因此任何具有 XA_RECOVER_ADMIN 权限的会话都可以提交或回滚它们。If true, and the handling session has executed an internal-use BINLOG statement, XA transactions are automatically detached from the session as soon as the first part of the transaction up to XA PREPARE finishes, so they can be committed or rolled back by any session that has the XA_RECOVER_ADMIN privilege.

    • 如果为假,XA 事务在处理会话存在期间会一直附加于该会话,在此期间没有其他会话可以提交事务。只有当会话断开或服务器重启时,准备好的事务才会被分离。If false, XA transactions remain attached to the handling session as long as that session is alive, during which time no other session can commit the transaction. The prepared transaction is only detached if the session disconnects or the server restarts.

    pseudo_replica_mode 对 original_commit_timestamp 复制延迟时间戳和 original_server_version 系统变量有以下影响:pseudo_replica_mode has the following effects on the original_commit_timestamp replication delay timestamp and the original_server_version system variable:

    • 如果为真,未明确设置 original_commit_timestamp 或 original_server_version 的事务将被视为源自另一个未知服务器,因此时间戳和系统变量都分配值 0,表示未知。If true, transactions that do not explicitly set original_commit_timestamp or original_server_version are assumed to originate on another, unknown server, so the value 0, meaning unknown, is assigned to both the timestamp and the system variable.

    • 如果为 false,则没有显式设置 original_commit_timestamp 或 original_server_version 的事务将假定源自当前服务器,因此当前时间戳和当前服务器的版本将被分配给时间戳和系统变量。If false, transactions that do not explicitly set original_commit_timestamp or original_server_version are assumed to originate on the current server, so the current timestamp and the current server's version are assigned to the timestamp and the system variable.

    pseudo_replica_mode 对设置一个或多个不受支持(已移除或未知)的 SQL 模式的语句的处理有以下影响:pseudo_replica_mode has the following effects on the handling of a statement that sets one or more unsupported (removed or unknown) SQL modes:

    • 如果为 true,服务器将忽略不受支持的模式并发出警告。If true, the server ignores the unsupported mode and raises a warning.

    • 如果为假,服务器会拒绝该语句,并返回ER_UNSUPPORTED_SQL_MODE。If false, the server rejects the statement with ER_UNSUPPORTED_SQL_MODE.

  • pseudo_slave_mode

    已弃用Deprecated 是Yes
    系统变量System Variable pseudo_slave_mode
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean

    已弃用的 pseudo_replica_mode 的别名。Deprecated alias for pseudo_replica_mode.

  • pseudo_thread_id

    系统变量System Variable pseudo_thread_id
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 2147483647
    最小值Minimum Value 0
    最大值Maximum Value 2147483647

    该变量供服务器内部使用。This variable is for internal server use.

    Warning

    更改 pseudo_thread_id 系统变量的会话值会更改 CONNECTION_ID() 函数返回的值。Changing the session value of the pseudo_thread_id system variable changes the value returned by the CONNECTION_ID() function.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • query_alloc_block_size

    命令行格式Command-Line Format --query-alloc-block-size=#
    系统变量System Variable query_alloc_block_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8192
    最小值Minimum Value 1024
    最大值Maximum Value 4294966272
    单位Unit 字节bytes
    块大小Block Size 1024

    在语句解析和执行过程中为对象分配的内存块的字节数。如果您遇到内存碎片问题,增加此参数可能会有所帮助。The allocation size in bytes of memory blocks that are allocated for objects created during statement parsing and execution. If you have problems with memory fragmentation, it might help to increase this parameter.

    字节数的块大小为 1024。不是块大小整数倍的值在存储系统变量的值之前,MySQL 服务器会向下舍入到块大小的下一个较低倍数。解析器允许的值最大可达平台的无符号整数最大值(32 位系统为 4294967295 或 232−1,64 位系统为 18446744073709551615 或 264−1),但实际最大值比块大小少一。The block size for the byte number is 1024. A value that is not an exact multiple of the block size is rounded down to the next lower multiple of the block size by MySQL Server before storing the value for the system variable. The parser allows values up to the maximum unsigned integer value for the platform (4294967295 or 232−1 for a 32-bit system, 18446744073709551615 or 264−1 for a 64-bit system) but the actual maximum is a block size lower.

  • query_prealloc_size

    命令行格式Command-Line Format --query-prealloc-size=#
    已弃用Deprecated 是Yes
    系统变量System Variable query_prealloc_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8192
    最小值Minimum Value 8192
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709550592
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294966272
    单位Unit 字节bytes
    块大小Block Size 1024

    query_prealloc_size 已不推荐使用,设置它不会产生效果;您应该预期它将在 MySQL 的未来版本中被移除。query_prealloc_size is deprecated, and setting it has no effect; you should expect its removal in a future release of MySQL.

  • rand_seed1

    系统变量System Variable rand_seed1
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value N/AN/A
    最小值Minimum Value 0
    最大值Maximum Value 4294967295

    rand_seed1 和 rand_seed2 变量仅作为会话变量存在,可以设置但不能读取。变量本身——而不是它们的值——会显示在 SHOW VARIABLES 的输出中。The rand_seed1 and rand_seed2 variables exist as session variables only, and can be set but not read. The variables—but not their values—are shown in the output of SHOW VARIABLES.

    这些变量的目的是支持 RAND() 函数的复制。对于调用 RAND() 的语句,源端会将两个值传递给副本,这些值用于为随机数生成器设置种子。副本使用这些值来设置会话变量 rand_seed1 和 rand_seed2,从而使副本上的 RAND() 生成的值与源端相同。The purpose of these variables is to support replication of the RAND() function. For statements that invoke RAND(), the source passes two values to the replica, where they are used to seed the random number generator. The replica uses these values to set the session variables rand_seed1 and rand_seed2 so that RAND() on the replica generates the same value as on the source.

  • rand_seed2

    参见 rand_seed1 的描述。See the description for rand_seed1.

  • range_alloc_block_size

    命令行格式Command-Line Format --range-alloc-block-size=#
    系统变量System Variable range_alloc_block_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 4096
    最小值Minimum Value 4096
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709550592
    最大值Maximum Value 4294966272
    单位Unit 字节bytes
    块大小Block Size 1024

    在进行范围优化时分配块的字节大小。The size in bytes of blocks that are allocated when doing range optimization.

    字节数的块大小为 1024。不是块大小整数倍的值在存储系统变量的值之前,MySQL 服务器会向下舍入到块大小的下一个较低倍数。解析器允许的值最大可达平台的无符号整数最大值(32 位系统为 4294967295 或 232−1,64 位系统为 18446744073709551615 或 264−1),但实际最大值比块大小少一。The block size for the byte number is 1024. A value that is not an exact multiple of the block size is rounded down to the next lower multiple of the block size by MySQL Server before storing the value for the system variable. The parser allows values up to the maximum unsigned integer value for the platform (4294967295 or 232−1 for a 32-bit system, 18446744073709551615 or 264−1 for a 64-bit system) but the actual maximum is a block size lower.

  • range_optimizer_max_mem_size

    命令行格式Command-Line Format --range-optimizer-max-mem-size=#
    系统变量System Variable range_optimizer_max_mem_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 8388608
    最小值Minimum Value 0
    最大值Maximum Value 18446744073709551615
    单位Unit 字节bytes

    范围优化器的内存消耗限制。值为 0 表示 “无限制。” 如果优化器考虑的执行计划使用范围访问方法,但优化器估计该方法所需的内存将超过限制,则它会放弃此计划并考虑其他计划。有关更多信息,请参阅 限制范围优化的内存使用。The limit on memory consumption for the range optimizer. A value of 0 means “no limit.” If an execution plan considered by the optimizer uses the range access method but the optimizer estimates that the amount of memory needed for this method would exceed the limit, it abandons the plan and considers other plans. For more information, see Limiting Memory Use for Range Optimization.

  • rbr_exec_mode

    系统变量System Variable rbr_exec_mode
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value STRICTSTRICT
    有效值Valid Values

    STRICTSTRICT

    IDEMPOTENTIDEMPOTENT

    供 mysqlbinlog 内部使用。此变量用于在服务器之间切换 IDEMPOTENT 模式和 STRICT 模式。IDEMPOTENT 模式会在由 mysqlbinlog 生成的 BINLOG 语句中抑制重复键和未找到键的错误。当在导致与现有数据冲突的服务器上重放基于行的二进制日志时,此模式非常有用。当你通过指定 --idempotent 选项时,mysqlbinlog 会设置此模式,并将以下内容写入输出:For internal use by mysqlbinlog. This variable switches the server between IDEMPOTENT mode and STRICT mode. IDEMPOTENT mode causes suppression of duplicate-key and no-key-found errors in BINLOG statements generated by mysqlbinlog. This mode is useful when replaying a row-based binary log on a server that causes conflicts with existing data. mysqlbinlog sets this mode when you specify the --idempotent option by writing the following to the output:

    SET SESSION RBR_EXEC_MODE=IDEMPOTENT;
  • read_buffer_size

    命令行格式Command-Line Format --read-buffer-size=#
    系统变量System Variable read_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 131072
    最小值Minimum Value 8192
    最大值Maximum Value 2147479552
    单位Unit 字节bytes
    块大小Block Size 4096

    每个为 MyISAM 表进行顺序扫描的线程都会为其扫描的每个表分配一个该大小(以字节为单位)的缓冲区。如果您进行许多顺序扫描,您可能希望增加此值,默认值为 131072。此变量的值应为 4KB 的倍数。如果设置为非 4KB 的倍数,则其值会向下舍入到最接近的 4KB 倍数。Each thread that does a sequential scan for a MyISAM table allocates a buffer of this size (in bytes) for each table it scans. If you do many sequential scans, you might want to increase this value, which defaults to 131072. The value of this variable should be a multiple of 4KB. If it is set to a value that is not a multiple of 4KB, its value is rounded down to the nearest multiple of 4KB.

    此选项也用于除 InnoDB 之外的所有其他存储引擎的以下情况:This option is also used in the following context for all other storage engines with the exception of InnoDB:

    • 在对 ORDER BY 排序行时,用于将索引缓存到临时文件(而不是临时表)中。For caching the indexes in a temporary file (not a temporary table), when sorting rows for ORDER BY.

    • 用于向分区进行批量插入。For bulk insert into partitions.

    • 用于缓存嵌套查询的结果。For caching results of nested queries.

    read_buffer_size 还在另一种特定于存储引擎的方式中使用:用于确定 MEMORY 表的内存块大小。read_buffer_size is also used in one other storage engine-specific way: to determine the memory block size for MEMORY tables.

    select_into_buffer_size 用于 SELECT INTO DUMPFILE 和 SELECT INTO OUTFILE 语句的 I/O 缓存缓冲区。(read_buffer_size 用于其他所有情况下的 I/O 缓存缓冲区大小。)select_into_buffer_size is used for the I/O cache buffer for SELECT INTO DUMPFILE and SELECT INTO OUTFILE statements. (read_buffer_size is used for the I/O cache buffer size in all other cases.)

    有关在不同操作期间内存使用的更多信息,请参见 第 10.12.3.1 节,“MySQL 如何使用内存”。For more information about memory use during different operations, see Section 10.12.3.1, “How MySQL Uses Memory”.

  • read_only

    命令行格式Command-Line Format --read-only[={OFF|ON}]--read-only[={OFF|ON}]
    系统变量System Variable read_only
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果 read_only 系统变量启用,服务器不允许客户端进行更新,除非用户拥有 CONNECTION_ADMIN 权限(或已弃用的 SUPER 权限)。此变量默认禁用。If the read_only system variable is enabled, the server permits no client updates except from users who have the CONNECTION_ADMIN privilege (or the deprecated SUPER privilege). This variable is disabled by default.

    服务器还支持一个 super_read_only 系统变量(默认禁用),其具有以下效果:The server also supports a super_read_only system variable (disabled by default), which has these effects:

    当 read_only 启用且 super_read_only 启用时,服务器仍然允许以下操作:When read_only is enabled and when super_read_only is enabled, the server still permits these operations:

    • 由复制线程执行的更新,如果服务器是副本。在复制设置中,在副本服务器上启用 read_only 可能是有用的,以确保副本只接受来自源服务器的更新,而不是来自客户端的更新。Updates performed by replication threads, if the server is a replica. In replication setups, it can be useful to enable read_only on replica servers to ensure that replicas accept updates only from the source server and not from clients.

    • 写入系统表 mysql.gtid_executed,该表存储当前二进制日志文件中不存在的已执行事务的 GTID。Writes to the system table mysql.gtid_executed, which stores GTIDs for executed transactions that are not present in the current binary log file.

    • 使用 ANALYZE TABLE 或 OPTIMIZE TABLE 语句。只读模式的目的是防止对表结构或内容进行更改。分析和优化不算作此类更改。这意味着,例如,可以使用 mysqlcheck --all-databases --analyze 对只读副本进行一致性检查。Use of ANALYZE TABLE or OPTIMIZE TABLE statements. The purpose of read-only mode is to prevent changes to table structure or contents. Analysis and optimization do not qualify as such changes. This means, for example, that consistency checks on read-only replicas can be performed with mysqlcheck --all-databases --analyze.

    • 使用FLUSH STATUS语句,这些语句总是被写入二进制日志。Use of FLUSH STATUS statements, which are always written to the binary log.

    • 对TEMPORARY表的操作。Operations on TEMPORARY tables.

    • 向日志表(mysql.general_log 和 mysql.slow_log)插入数据;参见第 7.4.1 节,“选择通用查询日志和慢查询日志的输出目的地”。Inserts into the log tables (mysql.general_log and mysql.slow_log); see Section 7.4.1, “Selecting General Query Log and Slow Query Log Output Destinations”.

    • 对性能模式表的更新操作,例如UPDATE或TRUNCATE TABLE操作。Updates to Performance Schema tables, such as UPDATE or TRUNCATE TABLE operations.

    对复制源服务器上的 read_only 的更改不会复制到副本服务器。副本上的值可以独立于源服务器的设置进行设置。Changes to read_only on a replication source server are not replicated to replica servers. The value can be set on a replica independent of the setting on the source.

    尝试启用 read_only 时(包括因为启用 super_read_only 而隐式尝试的情况),适用以下条件:The following conditions apply to attempts to enable read_only (including implicit attempts resulting from enabling super_read_only):

    • 如果您有任何显式锁(通过 LOCK TABLES 获取)或有待处理的事务,则尝试会失败并发生错误。The attempt fails and an error occurs if you have any explicit locks (acquired with LOCK TABLES) or have a pending transaction.

    • 当其他客户端有正在执行的语句、活动的 LOCK TABLES WRITE 或正在进行的提交时,尝试会被阻塞,直到锁被释放且语句和事务结束。在尝试启用 read_only 时挂起时,其他客户端对表锁或开始事务的请求也会被阻塞,直到 read_only 被设置。The attempt blocks while other clients have any ongoing statement, active LOCK TABLES WRITE, or ongoing commit, until the locks are released and the statements and transactions end. While the attempt to enable read_only is pending, requests by other clients for table locks or to begin transactions also block until read_only has been set.

    • 如果存在持有元数据锁的活动事务,尝试将被阻塞,直到这些事务结束。The attempt blocks if there are active transactions that hold metadata locks, until those transactions end.

    • read_only 可以在持有全局读取锁(通过 FLUSH TABLES WITH READ LOCK 获取)时启用,因为这不涉及表锁。read_only can be enabled while you hold a global read lock (acquired with FLUSH TABLES WITH READ LOCK) because that does not involve table locks.

  • read_rnd_buffer_size

    命令行格式Command-Line Format --read-rnd-buffer-size=#
    系统变量System Variable read_rnd_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 262144
    最小值Minimum Value 1
    最大值Maximum Value 2147483647
    单位Unit 字节bytes

    此变量用于从 MyISAM 表读取,并且对于任何存储引擎,用于多范围读取优化。This variable is used for reads from MyISAM tables, and, for any storage engine, for Multi-Range Read optimization.

    在对 MyISAM 表执行按键排序操作后按顺序读取行时,这些行会通过此缓冲区读取,以避免磁盘查找。请参见 第 10.2.1.16 节,“ORDER BY 优化”。将该变量设置为较大值可以大幅提高 ORDER BY 的性能。然而,这是为每个客户端分配的缓冲区,因此不应将全局变量设置为较大值。相反,应仅在那些需要运行大查询的客户端中更改会话变量。When reading rows from a MyISAM table in sorted order following a key-sorting operation, the rows are read through this buffer to avoid disk seeks. See Section 10.2.1.16, “ORDER BY Optimization”. Setting the variable to a large value can improve ORDER BY performance by a lot. However, this is a buffer allocated for each client, so you should not set the global variable to a large value. Instead, change the session variable only from within those clients that need to run large queries.

    有关在不同操作期间内存使用的更多信息,请参见第 10.12.3.1 节,“MySQL 如何使用内存”。有关多范围读取优化的信息,请参见第 10.2.1.11 节,“多范围读取优化”。For more information about memory use during different operations, see Section 10.12.3.1, “How MySQL Uses Memory”. For information about Multi-Range Read optimization, see Section 10.2.1.11, “Multi-Range Read Optimization”.

  • regexp_stack_limit

    命令行格式Command-Line Format --regexp-stack-limit=#
    系统变量System Variable regexp_stack_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8000000
    最小值Minimum Value 0
    最大值Maximum Value 2147483647
    单位Unit 字节bytes

    用于 REGEXP_LIKE() 及类似函数执行正则表达式匹配操作的内部堆栈可用最大内存(以字节为单位)(参见 第 14.8.2 节,“正则表达式”)。The maximum available memory in bytes for the internal stack used for regular expression matching operations performed by REGEXP_LIKE() and similar functions (see Section 14.8.2, “Regular Expressions”).

  • regexp_time_limit

    命令行格式Command-Line Format --regexp-time-limit=#
    系统变量System Variable regexp_time_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 32
    最小值Minimum Value 0
    最大值Maximum Value 2147483647

    由 REGEXP_LIKE() 及类似函数执行的正则表达式匹配操作的时间限制(参见 第 14.8.2 节,“正则表达式”)。该限制以匹配引擎执行的最大允许步骤数表示,因此只会间接影响执行时间。通常,该时间限制在毫秒级别。The time limit for regular expression matching operations performed by REGEXP_LIKE() and similar functions (see Section 14.8.2, “Regular Expressions”). This limit is expressed as the maximum permitted number of steps performed by the match engine, and thus affects execution time only indirectly. Typically, it is on the order of milliseconds.

  • require_row_format

    系统变量System Variable require_row_format
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此变量供复制和 mysqlbinlog 的服务器内部使用。它将会话中执行的 DML 事件限制为仅以行格式编码的二进制日志事件,并且不能创建临时表。不遵守这些限制的查询将会失败。This variable is for internal server use by replication and mysqlbinlog. It restricts DML events executed in the session to events encoded in row-based binary logging format only, and temporary tables cannot be created. Queries that do not respect the restrictions fail.

    将此系统变量的会话值设置为 ON 无需权限。将此系统变量的会话值设置为 OFF 是受限制的操作,会话用户必须具有足够的权限才能设置受限的会话变量。参见 第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable to ON requires no privileges. Setting the session value of this system variable to OFF is a restricted operation, and the session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • require_secure_transport

    命令行格式Command-Line Format --require-secure-transport[={OFF|ON}]--require-secure-transport[={OFF|ON}]
    系统变量System Variable require_secure_transport
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    是否要求客户端连接服务器时使用某种形式的安全传输。当启用此变量时,服务器仅允许使用 TLS/SSL 加密的 TCP/IP 连接,或使用套接字文件(在 Unix 上)或共享内存(在 Windows 上)的连接。服务器会拒绝非安全连接尝试,并返回 ER_SECURE_TRANSPORT_REQUIRED 错误。Whether client connections to the server are required to use some form of secure transport. When this variable is enabled, the server permits only TCP/IP connections encrypted using TLS/SSL, or connections that use a socket file (on Unix) or shared memory (on Windows). The server rejects nonsecure connection attempts, which fail with an ER_SECURE_TRANSPORT_REQUIRED error.

    此功能补充了每个账户的 SSL 要求,这些要求具有优先权。例如,如果账户被定义为 REQUIRE SSL,启用 require_secure_transport 并不能使该账户通过 Unix 套接字文件连接成为可能。This capability supplements per-account SSL requirements, which take precedence. For example, if an account is defined with REQUIRE SSL, enabling require_secure_transport does not make it possible to use the account to connect using a Unix socket file.

    服务器可能没有可用的安全传输。例如,如果在 Windows 上启动服务器时没有指定任何 SSL 证书或密钥文件,并且 shared_memory 系统变量被禁用,则服务器不支持任何安全传输。在这种情况下,尝试在启动时启用 require_secure_transport 会导致服务器在错误日志中写入一条消息并退出。在运行时尝试启用该变量会失败,并出现 ER_NO_SECURE_TRANSPORTS_CONFIGURED 错误。It is possible for a server to have no secure transports available. For example, a server on Windows supports no secure transports if started without specifying any SSL certificate or key files and with the shared_memory system variable disabled. Under these conditions, attempts to enable require_secure_transport at startup cause the server to write a message to the error log and exit. Attempts to enable the variable at runtime fail with an ER_NO_SECURE_TRANSPORTS_CONFIGURED error.

    所有复制组成员该变量的值应相同;否则,某些成员可能无法加入。All replication group members should have the same value for this variable; otherwise, some members may not be able to join.

    另请参阅 将加密连接配置为必需。See also Configuring Encrypted Connections as Mandatory.

  • restrict_fk_on_non_standard_key

    命令行格式Command-Line Format --restrict-fk-on-non-standard-key
    已弃用Deprecated 是Yes
    系统变量System Variable restrict_fk_on_non_standard_key
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    当这个变量为 ON(默认值)时,会阻止使用非唯一键或部分键作为外键。要在当前会话中允许将这些键用作外键,请使用 SET @@session.restrict_fk_on_non_standard_key=OFF;要全局允许使用它们,请设置全局变量或使用 --skip-restrict-fk-on-non-standard-key 启动服务器。This variable, when ON (the default), prevents the use of non-unique keys or partial keys as foreign keys. To allow such keys to be used as foreign keys in the current session, use SET @@session.restrict_fk_on_non_standard_key=OFF; to allow them to be used globally, set the global variable or start the server with --skip-restrict-fk-on-non-standard-key.

    在 CREATE TABLE 或 ALTER TABLE 语句中使用非唯一或部分键作为外键已被弃用,您应该预期在未来的 MySQL 版本中对其支持将被移除。当 restrict_fk_on_non_standard_key 为 ON 时,尝试这样做将被拒绝,并返回 ER_FK_NO_INDEX_PARENT;当其为 OFF 时,此用法被允许,但仍会以警告方式触发 ER_WARN_DEPRECATED_NON_STANDARD_KEY。Using non-unique or partial keys as foreign keys in a CREATE TABLE or ALTER TABLE statement is deprecated, and you should expect support for it to be removed in a future version of MySQL. When restrict_fk_on_non_standard_key is ON, attempts to do so are rejected with ER_FK_NO_INDEX_PARENT; when it is OFF, this usage is permitted but still raises ER_WARN_DEPRECATED_NON_STANDARD_KEY as a warning.

    restrict_fk_on_non_standard_key 已被弃用,并可能在未来的 MySQL 版本中移除。设置该选项会触发弃用警告。restrict_fk_on_non_standard_key is deprecated, and subject to removal in a future version of MySQL. Setting it raises a deprecation warning.

    对 MySQL 复制的影响。 当在主库的非标准键上创建外键时,如果 restrict_fk_on_non_standard_key 设置为 OFF,则该语句将在从库上成功执行,而不受从库上该变量设置的影响。Implication for MySQL Replication.  When a foreign key is created on a nonstandard key on the primary because restrict_fk_on_non_standard_key is OFF, the statement succeeds on the replica regardless of any setting on the replica for this variable.

  • resultset_metadata

    系统变量System Variable resultset_metadata
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value FULLFULL
    有效值Valid Values

    FULLFULL

    NONENONE

    对于元数据传输可选的连接,客户端设置resultset_metadata系统变量来控制服务器是否返回结果集元数据。允许的值为FULL(返回所有元数据;默认值)和NONE(不返回元数据)。For connections for which metadata transfer is optional, the client sets the resultset_metadata system variable to control whether the server returns result set metadata. Permitted values are FULL (return all metadata; this is the default) and NONE (return no metadata).

    对于非元数据可选的连接,将resultset_metadata设置为NONE会产生错误。For connections that are not metadata-optional, setting resultset_metadata to NONE produces an error.

    有关管理结果集元数据传输的详细信息,请参见可选结果集元数据。For details about managing result set metadata transfer, see Optional Result Set Metadata.

  • secondary_engine_cost_threshold

    仅用于 MySQL HeatWave。有关更多信息,请参阅 系统变量。For use with MySQL HeatWave only. See System Variables, for more information.

  • schema_definition_cache

    命令行格式Command-Line Format --schema-definition-cache=#
    系统变量System Variable schema_definition_cache
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 256
    最小值Minimum Value 256
    最大值Maximum Value 524288

    定义字典对象缓存中可保存的模式定义对象数量的上限,包括已使用和未使用的对象。Defines a limit for the number of schema definition objects, both used and unused, that can be kept in the dictionary object cache.

    未使用的模式定义对象仅在使用中的数量少于 schema_definition_cache 定义的容量时,才会保存在字典对象缓存中。Unused schema definition objects are only kept in the dictionary object cache when the number in use is less than the capacity defined by schema_definition_cache.

    设置 0 表示模式定义对象仅在使用时保存在字典对象缓存中。A setting of 0 means that schema definition objects are only kept in the dictionary object cache while they are in use.

    欲了解更多信息,请参见 第 16.4 节,“字典对象缓存”。For more information, see Section 16.4, “Dictionary Object Cache”.

  • secure_file_priv

    命令行格式Command-Line Format --secure-file-priv=dir_name
    系统变量System Variable secure_file_priv
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value platform specificplatform specific
    有效值Valid Values

    empty stringempty string

    dirname

    NULL

    此变量用于限制数据导入和导出操作的影响,例如 LOAD DATA 和 SELECT ... INTO OUTFILE 语句以及 LOAD_FILE() 函数执行的操作。只有拥有 FILE 权限的用户才允许进行这些操作。This variable is used to limit the effect of data import and export operations, such as those performed by the LOAD DATA and SELECT ... INTO OUTFILE statements and the LOAD_FILE() function. These operations are permitted only to users who have the FILE privilege.

    secure_file_priv 可以按如下方式设置:secure_file_priv may be set as follows:

    • 如果为空,该变量不起作用。这不是一个安全的设置。If empty, the variable has no effect. This is not a secure setting.

    • 如果设置为某个目录的名称,服务器将限制导入和导出操作仅处理该目录中的文件。该目录必须存在;服务器不会创建它。If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server does not create it.

    • 如果设置为NULL,服务器将禁用导入和导出操作。If set to NULL, the server disables import and export operations.

    默认值是特定于平台的,并依赖于INSTALL_LAYOUT CMake 选项的值,如下表所示。如果您从源代码构建并希望明确指定默认的 secure_file_priv 值,请使用 INSTALL_SECURE_FILE_PRIVDIR CMake 选项。The default value is platform specific and depends on the value of the INSTALL_LAYOUT CMake option, as shown in the following table. To specify the default secure_file_priv value explicitly if you are building from source, use the INSTALL_SECURE_FILE_PRIVDIR CMake option.

    INSTALL_LAYOUT 值INSTALL_LAYOUT Value 默认 secure_file_priv 值Default secure_file_priv Value
    STANDALONESTANDALONE 空empty
    DEB, RPM, SVR4 /var/lib/mysql-files/var/lib/mysql-files
    否则Otherwise mysql-files 位于 CMAKE_INSTALL_PREFIX 的值下mysql-files under the CMAKE_INSTALL_PREFIX value

    服务器在启动时会检查 secure_file_priv 的值,如果该值不安全,会在错误日志中写入警告。如果非 NULL 值为空,或者该值为数据目录或其子目录,或者为所有用户可访问的目录,则认为该值不安全。如果 secure_file_priv 设置为不存在的路径,服务器会在错误日志中写入错误信息并退出。The server checks the value of secure_file_priv at startup and writes a warning to the error log if the value is insecure. A non-NULL value is considered insecure if it is empty, or the value is the data directory or a subdirectory of it, or a directory that is accessible by all users. If secure_file_priv is set to a nonexistent path, the server writes an error message to the error log and exits.

  • select_into_buffer_size

    命令行格式Command-Line Format --select-into-buffer-size=#
    系统变量System Variable select_into_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 131072
    最小值Minimum Value 8192
    最大值Maximum Value 2147479552
    单位Unit 字节bytes
    块大小Block Size 4096

    在使用 SELECT INTO OUTFILE 或 SELECT INTO DUMPFILE 将数据导出到一个或多个文件用于备份创建、数据迁移或其他目的时,写入操作通常可以先缓冲,然后触发大量写入 I/O 活动到磁盘或其他存储设备,并阻塞其他对延迟更敏感的查询。您可以使用此变量来控制用于将数据写入存储设备的缓冲区大小,以确定何时进行缓冲区同步,从而防止前面所述的写入阻塞发生。When using SELECT INTO OUTFILE or SELECT INTO DUMPFILE to dump data into one or more files for backup creation, data migration, or other purposes, writes can often be buffered and then trigger a large burst of write I/O activity to the disk or other storage device and stall other queries that are more sensitive to latency. You can use this variable to control the size of the buffer used to write data to the storage device to determine when buffer synchronization should occur, and thus to prevent write stalls of the kind just described from occurring.

    select_into_buffer_size 会覆盖为 read_buffer_size 设置的任何值。(select_into_buffer_size 和 read_buffer_size 具有相同的默认值、最大值和最小值。)您还可以使用 select_into_disk_sync_delay 来设置每次同步发生后应观察的超时时间。select_into_buffer_size overrides any value set for read_buffer_size. (select_into_buffer_size and read_buffer_size have the same default, maximum, and minimum values.) You can also use select_into_disk_sync_delay to set a timeout to be observed afterwards, each time synchronization takes place.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • select_into_disk_sync

    命令行格式Command-Line Format --select-into-disk-sync={ON|OFF}
    系统变量System Variable select_into_disk_sync
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF
    有效值Valid Values

    OFFOFF

    ONON

    当设置为 ON 时,启用使用 select_into_buffer_size 进行缓冲同步,将长期运行的 SELECT INTO OUTFILE 或 SELECT INTO DUMPFILE 语句写入输出文件。When set on ON, enables buffer synchronization of writes to an output file by a long-running SELECT INTO OUTFILE or SELECT INTO DUMPFILE statement using select_into_buffer_size.

  • select_into_disk_sync_delay

    命令行格式Command-Line Format --select-into-disk-sync-delay=#
    系统变量System Variable select_into_disk_sync_delay
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 31536000
    单位Unit 毫秒milliseconds

    当通过长期运行的 SELECT INTO OUTFILE 或 SELECT INTO DUMPFILE 语句启用输出文件写入的缓冲区同步(由 select_into_disk_sync 控制)时,该变量设置同步后的可选延迟(以毫秒为单位)。0(默认值)表示没有延迟。When buffer synchronization of writes to an output file by a long-running SELECT INTO OUTFILE or SELECT INTO DUMPFILE statement is enabled by select_into_disk_sync, this variable sets an optional delay (in milliseconds) following synchronization. 0 (the default) means no delay.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • session_track_gtids

    命令行格式Command-Line Format --session-track-gtids=value
    系统变量System Variable session_track_gtids
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value OFFOFF
    有效值Valid Values

    OFFOFF

    OWN_GTID

    ALL_GTIDS

    控制服务器是否将 GTID 返回给客户端,从而使客户端能够使用它们来跟踪服务器状态。根据变量值,在执行每个事务结束时,服务器的 GTID 会被捕获并作为响应的一部分返回给客户端。session_track_gtids 的可能值如下:Controls whether the server returns GTIDs to the client, enabling the client to use them to track the server state. Depending on the variable value, at the end of executing each transaction, the server’s GTIDs are captured and returned to the client as part of the acknowledgement. The possible values for session_track_gtids are as follows:

    • OFF:服务器不将 GTID 返回给客户端。这是默认设置。OFF: The server does not return GTIDs to the client. This is the default.

    • OWN_GTID:服务器返回自上次确认以来,此客户端在当前会话中成功提交的所有事务的 GTID。通常,这是最后提交的事务的单个 GTID,但如果单个客户端请求导致了多个事务,服务器将返回包含所有相关 GTID 的 GTID 集合。OWN_GTID: The server returns the GTIDs for all transactions that were successfully committed by this client in its current session since the last acknowledgement. Typically, this is the single GTID for the last transaction committed, but if a single client request resulted in multiple transactions, the server returns a GTID set containing all the relevant GTIDs.

    • ALL_GTIDS:服务器返回其 gtid_executed 系统变量的全局值,该值在事务成功提交后读取。除了刚刚提交的事务的 GTID 外,这个 GTID 集合还包括任何客户端在服务器上提交的所有事务,并且可能包括在当前被确认的事务提交之后提交的事务。ALL_GTIDS: The server returns the global value of its gtid_executed system variable, which it reads at a point after the transaction is successfully committed. As well as the GTID for the transaction just committed, this GTID set includes all transactions committed on the server by any client, and can include transactions committed after the point when the transaction currently being acknowledged was committed.

    session_track_gtids 不能在事务上下文中设置。session_track_gtids cannot be set within transactional context.

    有关会话状态跟踪的更多信息,请参见 第 7.1.18 节,“服务器跟踪客户端会话状态”。For more information about session state tracking, see Section 7.1.18, “Server Tracking of Client Session State”.

  • session_track_schema

    命令行格式Command-Line Format --session-track-schema[={OFF|ON}]
    系统变量System Variable session_track_schema
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    控制服务器是否跟踪在当前会话中设置默认模式(数据库),并通知客户端使模式名称可用。Controls whether the server tracks when the default schema (database) is set within the current session and notifies the client to make the schema name available.

    如果启用模式名称追踪器,则每次设置默认模式时都会发生名称通知,即使新模式名称与旧名称相同。If the schema name tracker is enabled, name notification occurs each time the default schema is set, even if the new schema name is the same as the old.

    有关会话状态跟踪的更多信息,请参见 第 7.1.18 节,“服务器跟踪客户端会话状态”。For more information about session state tracking, see Section 7.1.18, “Server Tracking of Client Session State”.

  • session_track_state_change

    命令行格式Command-Line Format --session-track-state-change[={OFF|ON}]
    系统变量System Variable session_track_state_change
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    控制服务器是否跟踪当前会话状态的变化,并在状态发生变化时通知客户端。可以报告客户端会话状态的以下属性的变化:Controls whether the server tracks changes to the state of the current session and notifies the client when state changes occur. Changes can be reported for these attributes of client session state:

    • 默认模式(数据库)。The default schema (database).

    • 系统变量的会话特定值。Session-specific values for system variables.

    • 用户定义的变量。User-defined variables.

    • 临时表。Temporary tables.

    • 预处理语句。Prepared statements.

    如果启用了会话状态跟踪器,则每次涉及被跟踪会话属性的变化时都会发生通知,即使新属性值与旧值相同。例如,将用户定义的变量设置为其当前值会导致通知。If the session state tracker is enabled, notification occurs for each change that involves tracked session attributes, even if the new attribute values are the same as the old. For example, setting a user-defined variable to its current value results in a notification.

    session_track_state_change 变量只控制何时发生更改的通知,而不控制更改的具体内容。例如,当设置默认模式或分配被跟踪的会话系统变量时,会发生状态更改通知,但通知中不包括模式名称或变量值。要接收模式名称或会话系统变量值的通知,请分别使用 session_track_schema 或 session_track_system_variables 系统变量。The session_track_state_change variable controls only notification of when changes occur, not what the changes are. For example, state-change notifications occur when the default schema is set or tracked session system variables are assigned, but the notification does not include the schema name or variable values. To receive notification of the schema name or session system variable values, use the session_track_schema or session_track_system_variables system variable, respectively.

    Note

    将值分配给 session_track_state_change 本身不被视为状态更改,也不会作为状态更改进行报告。然而,如果它的名称列在 session_track_system_variables 的值中,对它的任何赋值确实会通知新值。Assigning a value to session_track_state_change itself is not considered a state change and is not reported as such. However, if its name listed in the value of session_track_system_variables, any assignments to it do result in notification of the new value.

    有关会话状态跟踪的更多信息,请参见 第 7.1.18 节,“服务器跟踪客户端会话状态”。For more information about session state tracking, see Section 7.1.18, “Server Tracking of Client Session State”.

  • session_track_system_variables

    命令行格式Command-Line Format --session-track-system-variables=#
    系统变量System Variable session_track_system_variables
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value time_zone, autocommit, character_set_client, character_set_results, character_set_connectiontime_zone, autocommit, character_set_client, character_set_results, character_set_connection

    控制服务器是否跟踪对会话系统变量的赋值,并将每个被赋值变量的名称和值通知客户端。变量值是一个以逗号分隔的变量列表,用于跟踪哪些变量的赋值。默认情况下,会通知time_zone、autocommit、character_set_client、character_set_results和character_set_connection。(后面三个变量是受SET NAMES影响的变量。)Controls whether the server tracks assignments to session system variables and notifies the client of the name and value of each assigned variable. The variable value is a comma-separated list of variables for which to track assignments. By default, notification is enabled for time_zone, autocommit, character_set_client, character_set_results, and character_set_connection. (The latter three variables are those affected by SET NAMES.)

    要启用显示每个处理语句的语句 ID,请使用 statement_id 变量。例如:To enable display of the Statement ID for each statement processed, use the statement_id variable. For example:

    mysql>  SET @@SESSION.session_track_system_variables='statement_id'
    mysql>  SELECT 1;
    +---+
    | 1 |
    +---+
    | 1 |
    +---+
    1 row in set (0.0006 sec)
    Statement ID: 603835
            

    特殊值 *(星号)会导致服务器跟踪所有会话变量的赋值。如果使用此值,必须单独指定,不能与特定系统变量名称一起使用。此值还可以启用显示每个成功处理语句的语句 ID。The special value * (asterisk) causes the server to track assignments to all session variables. If given, this value must be specified by itself without specific system variable names. This value also enables display of the Statement ID for each successful statement processed.

    要禁用会话变量赋值通知,请将 session_track_system_variables 设置为空字符串。To disable notification of session variable assignments, set session_track_system_variables to the empty string.

    如果启用了会话系统变量跟踪,即使新值与旧值相同,也会对所有被跟踪的会话变量赋值进行通知。If session system variable tracking is enabled, notification occurs for all assignments to tracked session variables, even if the new values are the same as the old.

    有关会话状态跟踪的更多信息,请参见 第 7.1.18 节,“服务器跟踪客户端会话状态”。For more information about session state tracking, see Section 7.1.18, “Server Tracking of Client Session State”.

  • session_track_transaction_info

    命令行格式Command-Line Format --session-track-transaction-info=value
    系统变量System Variable session_track_transaction_info
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value OFFOFF
    有效值Valid Values

    OFFOFF

    STATE

    CHARACTERISTICSCHARACTERISTICS

    控制服务器是否跟踪当前会话中事务的状态和特性,并通知客户端以使这些信息可用。允许的 session_track_transaction_info 值如下:Controls whether the server tracks the state and characteristics of transactions within the current session and notifies the client to make this information available. These session_track_transaction_info values are permitted:

    • OFF:禁用事务状态跟踪。这是默认值。OFF: Disable transaction state tracking. This is the default.

    • STATE:启用事务状态跟踪,但不跟踪特性。状态跟踪使客户端能够确定事务是否正在进行,以及事务是否可以在不回滚的情况下转移到不同的会话。STATE: Enable transaction state tracking without characteristics tracking. State tracking enables the client to determine whether a transaction is in progress and whether it could be moved to a different session without being rolled back.

    • CHARACTERISTICS:启用事务状态跟踪,包括特性跟踪。特性跟踪使客户端能够确定如何在另一个会话中重新启动事务,以便保持与原始会话相同的特性。以下特性与此目的相关:CHARACTERISTICS: Enable transaction state tracking, including characteristics tracking. Characteristics tracking enables the client to determine how to restart a transaction in another session so that it has the same characteristics as in the original session. The following characteristics are relevant for this purpose:

      ISOLATION LEVEL
      READ ONLY
      READ WRITE
      WITH CONSISTENT SNAPSHOT
      

    为了让客户端可以安全地将事务迁移到另一个会话,它不仅必须跟踪事务状态,还必须跟踪事务特性。此外,客户端必须跟踪 transaction_isolation 和 transaction_read_only 系统变量,以正确确定会话默认值。(要跟踪这些变量,请将它们列在 session_track_system_variables 系统变量的值中。)For a client to safely relocate a transaction to another session, it must track not only transaction state but also transaction characteristics. In addition, the client must track the transaction_isolation and transaction_read_only system variables to correctly determine the session defaults. (To track these variables, list them in the value of the session_track_system_variables system variable.)

    有关会话状态跟踪的更多信息,请参见 第 7.1.18 节,“服务器跟踪客户端会话状态”。For more information about session state tracking, see Section 7.1.18, “Server Tracking of Client Session State”.

  • set_operations_buffer_size

    命令行格式Command-Line Format --set-operations-buffer-size=#
    系统变量System Variable set_operations_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 256K
    最小值Minimum Value 16K
    最大值Maximum Value 1 GB
    单位Unit 字节bytes
    块大小Block Size 128

    设置使用哈希表的 INTERSECT 和 EXCEPT 操作的缓冲区大小,当 hash_set_operations 优化器开关为 ON 时生效。一般来说,当启用哈希优化时,增加此缓冲区的大小可以提高这些操作的性能。Sets the buffer size for INTERSECT and EXCEPT operations that use hash tables when the hash_set_operations optimizer switch is ON. In general, increasing the size of this buffer improves performance of these operations when the hashing optimization is enabled.

  • sha256_password_auto_generate_rsa_keys

    命令行格式Command-Line Format --sha256-password-auto-generate-rsa-keys[={OFF|ON}]
    已弃用Deprecated 是Yes
    系统变量System Variable sha256_password_auto_generate_rsa_keys
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    服务器使用此变量来确定是否在数据目录中自动生成 RSA 私钥/公钥对文件,如果它们尚不存在。The server uses this variable to determine whether to autogenerate RSA private/public key-pair files in the data directory if they do not already exist.

    启动时,如果满足以下条件,服务器会自动在数据目录中生成 RSA 私钥/公钥对文件:sha256_password_auto_generate_rsa_keys 或 caching_sha2_password_auto_generate_rsa_keys系统变量被启用;未指定 RSA 选项;RSA 文件在数据目录中缺失。这些密钥对文件允许通过 RSA 通过未加密连接安全交换密码,用于由sha256_password(弃用)或caching_sha2_password;参见 第 8.4.1.3 节,“SHA-256 可插拔认证”,以及 第 8.4.1.2 节,“缓存 SHA-2 可插拔认证”。At startup, the server automatically generates RSA private/public key-pair files in the data directory if all of these conditions are true: The sha256_password_auto_generate_rsa_keys or caching_sha2_password_auto_generate_rsa_keys system variable is enabled; no RSA options are specified; the RSA files are missing from the data directory. These key-pair files enable secure password exchange using RSA over unencrypted connections for accounts authenticated by the sha256_password (deprecated) or caching_sha2_password plugin; see Section 8.4.1.3, “SHA-256 Pluggable Authentication”, and Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.

    有关 RSA 文件自动生成的更多信息,包括文件名称和特性,请参阅 第 8.3.3.1 节,“使用 MySQL 创建 SSL 和 RSA 证书及密钥”For more information about RSA file autogeneration, including file names and characteristics, see Section 8.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”

    auto_generate_certs 系统变量相关,但它控制的是使用 SSL 进行安全连接所需的 SSL 证书和密钥文件的自动生成。The auto_generate_certs system variable is related but controls autogeneration of SSL certificate and key files needed for secure connections using SSL.

  • sha256_password_private_key_path

    命令行格式Command-Line Format --sha256-password-private-key-path=file_name--sha256-password-private-key-path=file_name
    已弃用Deprecated 是Yes
    系统变量System Variable sha256_password_private_key_path
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value private_key.pem

    该变量的值为 sha256_password(已废弃)认证插件的 RSA 私钥文件的路径名。如果文件名为相对路径,则相对于服务器数据目录进行解释。该文件必须为 PEM 格式。The value of this variable is the path name of the RSA private key file for the sha256_password (deprecated) authentication plugin. If the file is named as a relative path, it is interpreted relative to the server data directory. The file must be in PEM format.

    Important

    因为此文件存储了私钥,其访问模式应受到限制,以便只有 MySQL 服务器可以读取它。Because this file stores a private key, its access mode should be restricted so that only the MySQL server can read it.

    有关 sha256_password 的信息,请参见 第 8.4.1.3 节,“SHA-256 可插拔身份验证”。For information about sha256_password, see Section 8.4.1.3, “SHA-256 Pluggable Authentication”.

  • sha256_password_proxy_users

    命令行格式Command-Line Format --sha256-password-proxy-users[={OFF|ON}]
    已弃用Deprecated 是Yes
    系统变量System Variable sha256_password_proxy_users
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此变量控制sha256_password(已弃用)内置认证插件是否支持代理用户。除非启用了check_proxy_users系统变量,否则此设置无效。有关用户代理的信息,请参阅第 8.2.19 节,“代理用户”。This variable controls whether the sha256_password (deprecated) built-in authentication plugin supports proxy users. It has no effect unless the check_proxy_users system variable is enabled. For information about user proxying, see Section 8.2.19, “Proxy Users”.

  • sha256_password_public_key_path

    命令行格式Command-Line Format --sha256-password-public-key-path=file_name
    已弃用Deprecated 是Yes
    系统变量System Variable sha256_password_public_key_path
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value public_key.pem

    此变量的值是用于 sha256_password(已弃用)身份验证插件的 RSA 公钥文件的路径名。如果文件名是相对路径,则其解释是相对于服务器数据目录的。该文件必须为 PEM 格式。由于此文件存储的是公钥,因此可以自由分发给客户端用户。(当客户端在使用 RSA 密码加密连接到服务器时明确指定公钥时,必须使用与服务器使用的公钥相同的公钥。)The value of this variable is the path name of the RSA public key file for the sha256_password (deprecated) authentication plugin. If the file is named as a relative path, it is interpreted relative to the server data directory. The file must be in PEM format. Because this file stores a public key, copies can be freely distributed to client users. (Clients that explicitly specify a public key when connecting to the server using RSA password encryption must use the same public key as that used by the server.)

    有关 sha256_password(已弃用)的信息,包括客户端如何指定 RSA 公钥的信息,请参阅 第 8.4.1.3 节,“SHA-256 插件认证”。For information about sha256_password (deprecated), including information about how clients specify the RSA public key, see Section 8.4.1.3, “SHA-256 Pluggable Authentication”.

  • shared_memory

    命令行格式Command-Line Format --shared-memory[={OFF|ON}]
    系统变量System Variable shared_memory
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific 窗口Windows
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    (仅限 Windows。)服务器是否允许共享内存连接。(Windows only.) Whether the server permits shared-memory connections.

  • shared_memory_base_name

    命令行格式Command-Line Format --shared-memory-base-name=name--shared-memory-base-name=name
    系统变量System Variable shared_memory_base_name
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    特定平台Platform Specific 窗口Windows
    类型Type 字符串String
    默认值Default Value MYSQL

    (仅限 Windows。)用于共享内存连接的共享内存名称。当在单台物理机器上运行多个 MySQL 实例时,这非常有用。默认名称是 MYSQL。名称区分大小写。(Windows only.) The name of shared memory to use for shared-memory connections. This is useful when running multiple MySQL instances on a single physical machine. The default name is MYSQL. The name is case-sensitive.

    仅当服务器启动时启用了 shared_memory 系统变量以支持共享内存连接时,此变量才适用。This variable applies only if the server is started with the shared_memory system variable enabled to support shared-memory connections.

  • show_create_table_skip_secondary_engine

    仅用于 MySQL HeatWave。有关更多信息,请参阅 系统变量。For use with MySQL HeatWave only. See System Variables, for more information.

  • show_create_table_verbosity

    命令行格式Command-Line Format --show-create-table-verbosity[={OFF|ON}]
    系统变量System Variable show_create_table_verbosity
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    SHOW CREATE TABLE 通常不会显示 ROW_FORMAT 表选项,如果行格式是默认格式。启用此变量会使 SHOW CREATE TABLE 显示 ROW_FORMAT,无论它是否为默认格式。SHOW CREATE TABLE normally does not show the ROW_FORMAT table option if the row format is the default format. Enabling this variable causes SHOW CREATE TABLE to display ROW_FORMAT regardless of whether it is the default format.

  • show_gipk_in_create_table_and_information_schema

    命令行格式Command-Line Format --show-gipk-in-create-table-and-information-schema[={OFF|ON}]
    系统变量System Variable show_gipk_in_create_table_and_information_schema
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    是否在 SHOW 语句输出和信息模式表中显示生成的隐形主键。当该变量设置为 OFF 时,此类键不会显示。Whether generated invisible primary keys are visible in the output of SHOW statements and in Information Schema tables. When this variable is set to OFF, such keys are not shown.

    此变量不进行复制。This variable is not replicated.

    有关更多信息,请参阅 第 15.1.20.11 节,“生成的不可见主键”。For more information, see Section 15.1.20.11, “Generated Invisible Primary Keys”.

  • skip_external_locking

    命令行格式Command-Line Format --skip-external-locking[={OFF|ON}]
    系统变量System Variable skip_external_locking
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果 mysqld 使用外部锁(系统锁),则此值为 OFF;如果外部锁被禁用,则为 ON。这只影响 MyISAM 表的访问。This is OFF if mysqld uses external locking (system locking), ON if external locking is disabled. This affects only MyISAM table access.

    该变量可通过 --external-locking 或 --skip-external-locking 选项设置。默认情况下,外部锁是禁用的。This variable is set by the --external-locking or --skip-external-locking option. External locking is disabled by default.

    外部锁定仅影响 MyISAM 表的访问。有关更多信息,包括可用和不可用的条件,请参见 第 10.11.5 节,“外部锁定”。External locking affects only MyISAM table access. For more information, including conditions under which it can and cannot be used, see Section 10.11.5, “External Locking”.

  • skip_name_resolve

    命令行格式Command-Line Format --skip-name-resolve[={OFF|ON}]
    系统变量System Variable skip_name_resolve
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    检查客户端连接时是否解析主机名。如果此变量为OFF,mysqld在检查客户端连接时会解析主机名。如果为ON,mysqld仅使用 IP 地址;在这种情况下,授权表中的所有Host列值必须是 IP 地址。参见第 7.1.12.3 节,“DNS 查询和主机缓存”。Whether to resolve host names when checking client connections. If this variable is OFF, mysqld resolves host names when checking client connections. If it is ON, mysqld uses only IP numbers; in this case, all Host column values in the grant tables must be IP addresses. See Section 7.1.12.3, “DNS Lookups and the Host Cache”.

    根据系统的网络配置以及您账户的Host值,客户端可能需要使用显式的--host选项进行连接,例如--host=127.0.0.1或--host=::1。Depending on the network configuration of your system and the Host values for your accounts, clients may need to connect using an explicit --host option, such as --host=127.0.0.1 or --host=::1.

    尝试连接到主机 127.0.0.1 通常会解析为 localhost 账户。然而,如果服务器在启用 skip_name_resolve 时运行,这将失败。如果你计划这样做,请确保存在可以接受连接的账户。例如,要能够使用 --host=127.0.0.1 或 --host=::1 以 root 用户身份连接,请创建这些账户:An attempt to connect to the host 127.0.0.1 normally resolves to the localhost account. However, this fails if the server is run with skip_name_resolve enabled. If you plan to do that, make sure an account exists that can accept a connection. For example, to be able to connect as root using --host=127.0.0.1 or --host=::1, create these accounts:

    CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'root-password';
    CREATE USER 'root'@'::1' IDENTIFIED BY 'root-password';
    
  • skip_networking

    命令行格式Command-Line Format --skip-networking[={OFF|ON}]
    系统变量System Variable skip_networking
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    该变量控制服务器是否允许 TCP/IP 连接。默认情况下,它是禁用的(允许 TCP 连接)。如果启用,服务器只允许本地(非 TCP/IP)连接,并且所有与 mysqld 的交互必须使用命名管道或共享内存(在 Windows 上)或 Unix 套接字文件(在 Unix 上)。强烈建议在仅允许本地客户端的系统上使用此选项。请参阅 第 7.1.12.3 节,“DNS 查询和主机缓存”。This variable controls whether the server permits TCP/IP connections. By default, it is disabled (permit TCP connections). If enabled, the server permits only local (non-TCP/IP) connections and all interaction with mysqld must be made using named pipes or shared memory (on Windows) or Unix socket files (on Unix). This option is highly recommended for systems where only local clients are permitted. See Section 7.1.12.3, “DNS Lookups and the Host Cache”.

    由于使用 --skip-grant-tables 启动服务器会禁用身份验证检查,因此在这种情况下服务器还会通过启用 skip_networking 来禁用远程连接。Because starting the server with --skip-grant-tables disables authentication checks, the server also disables remote connections in that case by enabling skip_networking.

  • skip_show_database

    命令行格式Command-Line Format --skip-show-database
    系统变量System Variable skip_show_database
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果用户没有 SHOW DATABASES 权限,这将阻止他们使用 SHOW DATABASES 语句。如果您担心用户能够看到属于其他用户的数据库,这可以提高安全性。其效果取决于 SHOW DATABASES 权限:如果变量值为 ON,SHOW DATABASES 语句仅允许具有 SHOW DATABASES 权限的用户执行,并显示所有数据库名称。如果值为 OFF,则 SHOW DATABASES 允许所有用户执行,但只显示该用户拥有 SHOW DATABASES 或其他权限的数据库名称。This prevents people from using the SHOW DATABASES statement if they do not have the SHOW DATABASES privilege. This can improve security if you have concerns about users being able to see databases belonging to other users. Its effect depends on the SHOW DATABASES privilege: If the variable value is ON, the SHOW DATABASES statement is permitted only to users who have the SHOW DATABASES privilege, and the statement displays all database names. If the value is OFF, SHOW DATABASES is permitted to all users, but displays the names of only those databases for which the user has the SHOW DATABASES or other privilege.

    Caution

    因为任何静态全局权限都被视为对所有数据库的权限,所以任何静态全局权限都可以使用户通过 SHOW DATABASES 查看所有数据库名称,或通过检查 SCHEMATA 表(位于 INFORMATION_SCHEMA 中)来查看所有数据库名称,但被数据库级别的部分撤销限制的数据库除外。Because any static global privilege is considered a privilege for all databases, any static global privilege enables a user to see all database names with SHOW DATABASES or by examining the SCHEMATA table of INFORMATION_SCHEMA, except databases that have been restricted at the database level by partial revokes.

  • slow_launch_time

    命令行格式Command-Line Format --slow-launch-time=#
    系统变量System Variable slow_launch_time
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 2
    最小值Minimum Value 0
    最大值Maximum Value 31536000
    单位Unit 秒seconds

    如果创建线程所需时间超过此秒数,服务器会增加 Slow_launch_threads 状态变量。If creating a thread takes longer than this many seconds, the server increments the Slow_launch_threads status variable.

  • slow_query_log

    命令行格式Command-Line Format --slow-query-log[={OFF|ON}]
    系统变量System Variable slow_query_log
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    是否启用了慢查询日志。该值可以为 0(或 OFF)以禁用日志,或者为 1(或 ON)以启用日志。日志输出的目的地由 log_output 系统变量控制;如果该值为 NONE,即使日志已启用,也不会写入任何日志条目。Whether the slow query log is enabled. The value can be 0 (or OFF) to disable the log or 1 (or ON) to enable the log. The destination for log output is controlled by the log_output system variable; if that value is NONE, no log entries are written even if the log is enabled.

    “慢” 是由 long_query_time 变量的值决定的。参见 第 7.4.5 节,“慢查询日志”。“Slow” is determined by the value of the long_query_time variable. See Section 7.4.5, “The Slow Query Log”.

  • slow_query_log_file

    命令行格式Command-Line Format --slow-query-log-file=file_name
    系统变量System Variable slow_query_log_file
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value host_name-slow.log

    慢查询日志文件的名称。默认值是 host_name-slow.log,但可以通过 --slow_query_log_file 选项更改初始值。The name of the slow query log file. The default value is host_name-slow.log, but the initial value can be changed with the --slow_query_log_file option.

  • socket

    命令行格式Command-Line Format --socket={file_name|pipe_name}--socket={file_name|pipe_name}
    系统变量System Variable socket
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值(Windows)Default Value (Windows) MySQLMySQL
    默认值(其他)Default Value (Other) /tmp/mysql.sock/tmp/mysql.sock

    在 Unix 平台上,该变量是用于本地客户端连接的套接字文件的名称。默认值是 /tmp/mysql.sock。(对于某些发行版格式,目录可能不同,例如 RPM 的 /var/lib/mysql。)On Unix platforms, this variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock. (For some distribution formats, the directory might be different, such as /var/lib/mysql for RPMs.)

    在 Windows 上,该变量是用于本地客户端连接的命名管道的名称。默认值是 MySQL(不区分大小写)。On Windows, this variable is the name of the named pipe that is used for local client connections. The default value is MySQL (not case-sensitive).

  • sort_buffer_size

    命令行格式Command-Line Format --sort-buffer-size=#
    系统变量System Variable sort_buffer_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 262144
    最小值Minimum Value 32768
    最大值(Windows)Maximum Value (Windows) 4294967295
    最大值(其他,64 位平台)Maximum Value (Other, 64-bit platforms) 18446744073709551615
    最大值(其他,32 位平台)Maximum Value (Other, 32-bit platforms) 4294967295
    单位Unit 字节bytes

    每个必须执行排序的会话都会分配一个此大小的缓冲区。sort_buffer_size 并不特定于任何存储引擎,而是以通用方式进行优化。至少,sort_buffer_size 的值必须足够大,以容纳排序缓冲区中的十五个元组。此外,增加 max_sort_length 的值可能需要增加 sort_buffer_size 的值。更多信息,请参见 第 10.2.1.16 节,“ORDER BY 优化”Each session that must perform a sort allocates a buffer of this size. sort_buffer_size is not specific to any storage engine and applies in a general manner for optimization. At minimum the sort_buffer_size value must be large enough to accommodate fifteen tuples in the sort buffer. Also, increasing the value of max_sort_length may require increasing the value of sort_buffer_size. For more information, see Section 10.2.1.16, “ORDER BY Optimization”

    如果你在 Sort_merge_passes 输出中每秒看到很多 SHOW GLOBAL STATUS,你可以考虑增加 sort_buffer_size 值,以加快无法通过查询优化或改进索引提高的 ORDER BY 或 GROUP BY 操作的速度。If you see many Sort_merge_passes per second in SHOW GLOBAL STATUS output, you can consider increasing the sort_buffer_size value to speed up ORDER BY or GROUP BY operations that cannot be improved with query optimization or improved indexing.

    优化器会尝试计算所需的空间,但可以分配更多,最多到限制为止。将其设置得比全局需求更大会减慢大多数执行排序的查询速度。最好将其作为会话设置增加,并且仅对需要更大大小的会话使用。在 Linux 上,有 256KB 和 2MB 的阈值,超过这些值可能会显著减慢内存分配,因此你应考虑保持在这些值之一以下。可以通过实验找到适合你工作负载的最佳值。参见 B.3.3.5 节,“MySQL 存储临时文件的位置”。The optimizer tries to work out how much space is needed but can allocate more, up to the limit. Setting it larger than required globally slows down most queries that perform sorts. It is best to increase it as a session setting, and only for the sessions that need a larger size. On Linux, there are thresholds of 256KB and 2MB where larger values may significantly slow down memory allocation, so you should consider staying below one of those values. Experiment to find the best value for your workload. See Section B.3.3.5, “Where MySQL Stores Temporary Files”.

    sort_buffer_size 的最大允许设置为 4GB−1。对于 64 位平台允许更大的值(除了 64 位 Windows,对于其,大值会被截断为 4GB−1 并发出警告)。The maximum permissible setting for sort_buffer_size is 4GB−1. Larger values are permitted for 64-bit platforms (except 64-bit Windows, for which large values are truncated to 4GB−1 with a warning).

  • sql_auto_is_null

    系统变量System Variable sql_auto_is_null
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果启用此变量,那么在成功插入自动生成的 AUTO_INCREMENT 值之后,您可以通过执行以下形式的语句来找到该值:If this variable is enabled, then after a statement that successfully inserts an automatically generated AUTO_INCREMENT value, you can find that value by issuing a statement of the following form:

    SELECT * FROM tbl_name WHERE auto_col IS NULL
    

    如果该语句返回一行,则返回的值与调用 LAST_INSERT_ID() 函数时返回的值相同。有关详细信息,包括多行插入后的返回值,请参见 第 14.15 节,“信息函数”。如果没有成功插入 AUTO_INCREMENT 值,则 SELECT 语句不返回任何行。If the statement returns a row, the value returned is the same as if you invoked the LAST_INSERT_ID() function. For details, including the return value after a multiple-row insert, see Section 14.15, “Information Functions”. If no AUTO_INCREMENT value was successfully inserted, the SELECT statement returns no row.

    通过使用IS NULL 比较来检索 AUTO_INCREMENT 值的行为被一些 ODBC 程序(如 Access)使用。请参见 获取自增值。通过将 sql_auto_is_null 设置为 OFF 可以禁用此行为。The behavior of retrieving an AUTO_INCREMENT value by using an IS NULL comparison is used by some ODBC programs, such as Access. See Obtaining Auto-Increment Values. This behavior can be disabled by setting sql_auto_is_null to OFF.

    sql_auto_is_null 的默认值为 OFF。The default value of sql_auto_is_null is OFF.

  • sql_big_selects

    系统变量System Variable sql_big_selects
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果设置为 OFF,MySQL 会中止那些可能执行时间非常长的 SELECT 语句(也就是说,优化器估计检查的行数超过 max_join_size 值的语句)。当执行了不建议的 WHERE 语句时,这非常有用。新连接的默认值是 ON,允许所有 SELECT 语句。If set to OFF, MySQL aborts SELECT statements that are likely to take a very long time to execute (that is, statements for which the optimizer estimates that the number of examined rows exceeds the value of max_join_size). This is useful when an inadvisable WHERE statement has been issued. The default value for a new connection is ON, which permits all SELECT statements.

    如果将 max_join_size 系统变量设置为除 DEFAULT 以外的值,sql_big_selects 将被设置为 OFF。If you set the max_join_size system variable to a value other than DEFAULT, sql_big_selects is set to OFF.

  • sql_buffer_result

    系统变量System Variable sql_buffer_result
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果启用,sql_buffer_result 强制将 SELECT 语句的结果放入临时表中。这有助于 MySQL 提前释放表锁,并且在将结果发送给客户端需要很长时间的情况下可能有益。默认值为 OFF。If enabled, sql_buffer_result forces results from SELECT statements to be put into temporary tables. This helps MySQL free the table locks early and can be beneficial in cases where it takes a long time to send results to the client. The default value is OFF.

  • sql_generate_invisible_primary_key

    命令行格式Command-Line Format --sql-generate-invisible-primary-key[={OFF|ON}]
    系统变量System Variable sql_generate_invisible_primary_key
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此服务器是否会向任何没有主键的 InnoDB 表添加生成的隐藏主键。Whether this server adds a generated invisible primary key to any InnoDB table that is created without one.

    此变量不进行复制。此外,即使在从库上设置,它也会被复制应用线程忽略;这意味着默认情况下,从库不会为任何在源库上创建时没有主键的复制表生成主键。你可以通过在 REQUIRE_TABLE_PRIMARY_KEY_CHECK = GENERATE 语句中设置 CHANGE REPLICATION SOURCE TO 来让从库为这些表生成不可见主键,也可以选择指定复制通道。This variable is not replicated. In addition, even if set on the replica, it is ignored by replication applier threads; this means that, by default, a replica does not generate a primary key for any replicated table which, on the source, was created without one. You can cause the replica to generate invisible primary keys for such tables by setting REQUIRE_TABLE_PRIMARY_KEY_CHECK = GENERATE as part of a CHANGE REPLICATION SOURCE TO statement, optionally specifying a replication channel.

    更多信息和示例,请参见 第 15.1.20.11 节,“生成的不可见主键”。For more information and examples, see Section 15.1.20.11, “Generated Invisible Primary Keys”.

  • sql_log_off

    系统变量System Variable sql_log_off
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF
    有效值Valid Values

    OFF(启用日志记录)OFF (enable logging)

    ON(禁用日志记录)ON (disable logging)

    该变量控制当前会话是否禁用写入通用查询日志(假设通用查询日志本身已启用)。默认值为OFF(即启用日志记录)。要禁用或启用当前会话的通用查询日志,请将会话的sql_log_off变量设置为ON或OFF。This variable controls whether logging to the general query log is disabled for the current session (assuming that the general query log itself is enabled). The default value is OFF (that is, enable logging). To disable or enable general query logging for the current session, set the session sql_log_off variable to ON or OFF.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

  • sql_mode

    命令行格式Command-Line Format --sql-mode=name--sql-mode=name
    系统变量System Variable sql_mode
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 设置Set
    默认值Default Value ONLY_FULL_GROUP_BY STRICT_TRANS_TABLES NO_ZERO_IN_DATE NO_ZERO_DATE ERROR_FOR_DIVISION_BY_ZERO NO_ENGINE_SUBSTITUTIONONLY_FULL_GROUP_BY STRICT_TRANS_TABLES NO_ZERO_IN_DATE NO_ZERO_DATE ERROR_FOR_DIVISION_BY_ZERO NO_ENGINE_SUBSTITUTION
    有效值Valid Values

    ALLOW_INVALID_DATESALLOW_INVALID_DATES

    ANSI_QUOTESANSI_QUOTES

    ERROR_FOR_DIVISION_BY_ZEROERROR_FOR_DIVISION_BY_ZERO

    HIGH_NOT_PRECEDENCEHIGH_NOT_PRECEDENCE

    IGNORE_SPACEIGNORE_SPACE

    NO_AUTO_VALUE_ON_ZERONO_AUTO_VALUE_ON_ZERO

    NO_BACKSLASH_ESCAPESNO_BACKSLASH_ESCAPES

    NO_DIR_IN_CREATENO_DIR_IN_CREATE

    NO_ENGINE_SUBSTITUTIONNO_ENGINE_SUBSTITUTION

    NO_UNSIGNED_SUBTRACTIONNO_UNSIGNED_SUBTRACTION

    NO_ZERO_DATENO_ZERO_DATE

    NO_ZERO_IN_DATENO_ZERO_IN_DATE

    ONLY_FULL_GROUP_BYONLY_FULL_GROUP_BY

    PAD_CHAR_TO_FULL_LENGTHPAD_CHAR_TO_FULL_LENGTH

    PIPES_AS_CONCATPIPES_AS_CONCAT

    REAL_AS_FLOATREAL_AS_FLOAT

    STRICT_ALL_TABLESSTRICT_ALL_TABLES

    STRICT_TRANS_TABLESSTRICT_TRANS_TABLES

    TIME_TRUNCATE_FRACTIONALTIME_TRUNCATE_FRACTIONAL

    当前服务器的 SQL 模式,可以动态设置。有关详细信息,请参见 第 7.1.11 节,“服务器 SQL 模式”。The current server SQL mode, which can be set dynamically. For details, see Section 7.1.11, “Server SQL Modes”.

    Note

    MySQL 安装程序可能会在安装过程中配置 SQL 模式。MySQL installation programs may configure the SQL mode during the installation process.

    如果 SQL 模式与默认值或您预期的不同,请检查服务器在启动时读取的选项文件中的设置。If the SQL mode differs from the default or from what you expect, check for a setting in an option file that the server reads at startup.

  • sql_notes

    系统变量System Variable sql_notes
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果启用(默认设置),Note 级别的诊断会增加 warning_count,服务器会记录它们。如果禁用,Note 诊断不会增加 warning_count,服务器也不会记录它们。mysqldump 包括输出以禁用此变量,从而在重新加载转储文件时不会对不影响重新加载操作完整性的事件产生警告。If enabled (the default), diagnostics of Note level increment warning_count and the server records them. If disabled, Note diagnostics do not increment warning_count and the server does not record them. mysqldump includes output to disable this variable so that reloading the dump file does not produce warnings for events that do not affect the integrity of the reload operation.

  • sql_quote_show_create

    系统变量System Variable sql_quote_show_create
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果启用(默认值),服务器会在 SHOW CREATE TABLE 和 SHOW CREATE DATABASE 语句中引用标识符。如果禁用,则不进行引用。此选项默认启用,以便为需要引用的标识符实现复制。参见 第 15.7.7.11 节,“SHOW CREATE TABLE 语句” 以及 第 15.7.7.7 节,“SHOW CREATE DATABASE 语句”。If enabled (the default), the server quotes identifiers for SHOW CREATE TABLE and SHOW CREATE DATABASE statements. If disabled, quoting is disabled. This option is enabled by default so that replication works for identifiers that require quoting. See Section 15.7.7.11, “SHOW CREATE TABLE Statement”, and Section 15.7.7.7, “SHOW CREATE DATABASE Statement”.

  • sql_require_primary_key

    命令行格式Command-Line Format --sql-require-primary-key[={OFF|ON}]
    系统变量System Variable sql_require_primary_key
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    创建新表或修改现有表结构的语句是否强制要求表具有主键。Whether statements that create new tables or alter the structure of existing tables enforce the requirement that tables have a primary key.

    设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 7.1.9.1 节,“系统变量权限”。Setting the session value of this system variable is a restricted operation. The session user must have privileges sufficient to set restricted session variables. See Section 7.1.9.1, “System Variable Privileges”.

    启用此变量有助于避免在行级复制中由于表没有主键而可能出现的性能问题。假设一个表没有主键,并且一次更新或删除操作修改了多行。在复制源服务器上,这个操作可以通过一次表扫描来完成,但是在使用行级复制进行复制时,每一行要修改的操作都会在副本上进行一次表扫描。如果有主键,这些表扫描就不会发生。Enabling this variable helps avoid performance problems in row-based replication that can occur when tables have no primary key. Suppose that a table has no primary key and an update or delete modifies multiple rows. On the replication source server, this operation can be performed using a single table scan but, when replicated using row-based replication, results in a table scan for each row to be modified on the replica. With a primary key, these table scans do not occur.

    sql_require_primary_key 适用于基础表和 TEMPORARY 表,其值的更改会复制到副本服务器。表必须使用可以参与复制的 MySQL 存储引擎。sql_require_primary_key applies to both base tables and TEMPORARY tables, and changes to its value are replicated to replica servers. The table must use MySQL storage engines that can participate in replication.

    启用后,sql_require_primary_key具有以下效果:When enabled, sql_require_primary_key has these effects:

    • 尝试创建没有主键的新表将失败并报错。这包括CREATE TABLE ... LIKE。也包括CREATE TABLE ... SELECT,除非CREATE TABLE部分包含主键定义。Attempts to create a new table with no primary key fail with an error. This includes CREATE TABLE ... LIKE. It also includes CREATE TABLE ... SELECT, unless the CREATE TABLE part includes a primary key definition.

    • 尝试从现有表中删除主键将失败并报错,但允许在同一个ALTER TABLE语句中同时删除主键并添加主键。Attempts to drop the primary key from an existing table fail with an error, with the exception that dropping the primary key and adding a primary key in the same ALTER TABLE statement is permitted.

      即使表中还包含UNIQUE NOT NULL索引,删除主键仍会失败。Dropping the primary key fails even if the table also contains a UNIQUE NOT NULL index.

    • 尝试导入没有主键的表将失败并报错。Attempts to import a table with no primary key fail with an error.

    该REQUIRE_TABLE_PRIMARY_KEY_CHECK option of the CHANGE REPLICATION SOURCE TO statement enables a replica to select its own policy for primary key checks. When the option is set to ON for a replication channel, the replica always uses the value ON for the sql_require_primary_key system variable in replication operations, requiring a primary key. When the option is set to OFF, the replica always uses the value OFF for the sql_require_primary_key system variable in replication operations, so that a primary key is never required, even if the source required one. When the REQUIRE_TABLE_PRIMARY_KEY_CHECK option is set to STREAM, which is the default, the replica uses whatever value is replicated from the source for each transaction. With the STREAM setting for the REQUIRE_TABLE_PRIMARY_KEY_CHECK option, if privilege checks are in use for the replication channel, the PRIVILEGE_CHECKS_USER account needs privileges sufficient to set restricted session variables, so that it can set the session value for the sql_require_primary_key system variable. With the ON或者OFF settings, the account does not need these privileges. For more information, see Section 19.3.3, “Replication Privilege Checks”.The REQUIRE_TABLE_PRIMARY_KEY_CHECK option of the CHANGE REPLICATION SOURCE TO statement enables a replica to select its own policy for primary key checks. When the option is set to ON for a replication channel, the replica always uses the value ON for the sql_require_primary_key system variable in replication operations, requiring a primary key. When the option is set to OFF, the replica always uses the value OFF for the sql_require_primary_key system variable in replication operations, so that a primary key is never required, even if the source required one. When the REQUIRE_TABLE_PRIMARY_KEY_CHECK option is set to STREAM, which is the default, the replica uses whatever value is replicated from the source for each transaction. With the STREAM setting for the REQUIRE_TABLE_PRIMARY_KEY_CHECK option, if privilege checks are in use for the replication channel, the PRIVILEGE_CHECKS_USER account needs privileges sufficient to set restricted session variables, so that it can set the session value for the sql_require_primary_key system variable. With the ON or OFF settings, the account does not need these privileges. For more information, see Section 19.3.3, “Replication Privilege Checks”.

  • sql_safe_updates

    系统变量System Variable sql_safe_updates
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果启用此变量,未在 WHERE 子句或 LIMIT 子句中使用键的 UPDATE 和 DELETE 语句将产生错误。这使得可以捕获未正确使用键并可能更改或删除大量行的 UPDATE 和 DELETE 语句。默认值为 OFF。If this variable is enabled, UPDATE and DELETE statements that do not use a key in the WHERE clause or a LIMIT clause produce an error. This makes it possible to catch UPDATE and DELETE statements where keys are not used properly and that would probably change or delete a large number of rows. The default value is OFF.

    对于 mysql 客户端,可以使用 --safe-updates 选项启用 sql_safe_updates。更多信息请参见 使用安全更新模式 (--safe-updates)。For the mysql client, sql_safe_updates can be enabled by using the --safe-updates option. For more information, see Using Safe-Updates Mode (--safe-updates).

  • sql_select_limit

    系统变量System Variable sql_select_limit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 18446744073709551615
    最小值Minimum Value 0
    最大值Maximum Value 18446744073709551615

    从 SELECT 语句返回的最大行数。有关更多信息,请参见 使用安全更新模式 (--safe-updates)。The maximum number of rows to return from SELECT statements. For more information, see Using Safe-Updates Mode (--safe-updates).

    新连接的默认值是服务器每个表允许的最大行数。典型的默认值是 (232)−1 或 (264)−1。如果您已更改限制,可以通过分配 DEFAULT 值来恢复默认值。The default value for a new connection is the maximum number of rows that the server permits per table. Typical default values are (232)−1 or (264)−1. If you have changed the limit, the default value can be restored by assigning a value of DEFAULT.

    如果一个 SELECT 有 LIMIT 子句,则 LIMIT 优先于 sql_select_limit 的值。If a SELECT has a LIMIT clause, the LIMIT takes precedence over the value of sql_select_limit.

  • sql_warnings

    系统变量System Variable sql_warnings
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    此变量控制单行 INSERT 语句在发生警告时是否生成信息字符串。默认值为 OFF。将其设置为 ON 可生成信息字符串。This variable controls whether single-row INSERT statements produce an information string if warnings occur. The default is OFF. Set the value to ON to produce an information string.

  • ssl_ca

    命令行格式Command-Line Format --ssl-ca=file_name--ssl-ca=file_name
    系统变量System Variable ssl_ca
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    PEM 格式的证书颁发机构(CA)证书文件的路径名称。该文件包含受信任的 SSL 证书颁发机构列表。The path name of the Certificate Authority (CA) certificate file in PEM format. The file contains a list of trusted SSL Certificate Authorities.

    此变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 之后或在变量值已被持久化情况下重启后为新建立的连接使用的 TLS 上下文。请参阅 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_capath

    命令行格式Command-Line Format --ssl-capath=dir_name--ssl-capath=dir_name
    系统变量System Variable ssl_capath
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value NULL

    包含受信任的 SSL 证书颁发机构(CA)证书文件(PEM 格式)的目录的路径名。必须在使用该选项指定的目录之前运行 OpenSSL rehash。在 Linux 系统上,您可以这样调用 rehash:The path name of the directory that contains trusted SSL Certificate Authority (CA) certificate files in PEM format. You must run OpenSSL rehash on the directory specified by this option prior to using it. On Linux systems, you can invoke rehash like this:

    $> openssl rehash path/to/directory
    

    在 Windows 平台上,您可以在命令提示符下使用 c_rehash 脚本,如下所示:On Windows platforms, you can use the c_rehash script in a command prompt, like this:

    \> c_rehash path/to/directory
    

    有关完整的语法和其他信息,请参阅 openssl-rehash。See openssl-rehash for complete syntax and other information.

    这个变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 后或如果变量值已持久化,则在重新启动后为新建立的连接使用的 TLS 上下文。参见 服务器端加密连接的运行时配置和监控。This variable is can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_cert

    命令行格式Command-Line Format --ssl-cert=file_name--ssl-cert=file_name
    系统变量System Variable ssl_cert
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    服务器 SSL 公钥证书文件的路径名,格式为 PEM。The path name of the server SSL public key certificate file in PEM format.

    如果服务器启动时 ssl_cert 设置为使用任何受限制的密码或密码类别的证书,服务器将以禁用加密连接支持的方式启动。有关密码限制的信息,请参阅 连接密码配置。If the server is started with ssl_cert set to a certificate that uses any restricted cipher or cipher category, the server starts with support for encrypted connections disabled. For information about cipher restrictions, see Connection Cipher Configuration.

    此变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 之后或在变量值已被持久化情况下重启后为新建立的连接使用的 TLS 上下文。请参阅 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_cipher

    命令行格式Command-Line Format --ssl-cipher=name--ssl-cipher=name
    系统变量System Variable ssl_cipher
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value NULL

    允许用于使用 TLSv1.2 的连接的加密密码列表。如果列表中的任何密码都不被支持,则使用该 TLS 协议的加密连接将无法工作。The list of permissible encryption ciphers for connections that use TLSv1.2. If no cipher in the list is supported, encrypted connections that use this TLS protocol do not work.

    该列表可以包括以下任意值:The list may include any of the following values:

    • ECDHE-ECDSA-AES128-GCM-SHA256

    • ECDHE-ECDSA-AES256-GCM-SHA384

    • ECDHE-RSA-AES128-GCM-SHA256

    • ECDHE-RSA-AES256-GCM-SHA384

    • ECDHE-ECDSA-CHACHA20-POLY1305

    • ECDHE-RSA-CHACHA20-POLY1305

    • ECDHE-ECDSA-AES256-CCM

    • ECDHE-ECDSA-AES128-CCM

    • DHE-RSA-AES128-GCM-SHA256

    • DHE-RSA-AES256-GCM-SHA384

    • DHE-RSA-AES256-CCM

    • DHE-RSA-AES128-CCM

    • DHE-RSA-CHACHA20-POLY1305

    在设置此变量时,如果尝试在密码列表中包含此处未显示的任何值,将引发错误(ER_BLOCKED_CIPHER)。Trying to include any values in the cipher list that are not shown here when setting this variable raises an error (ER_BLOCKED_CIPHER).

    为了最大的可移植性,密码列表应为一个或多个密码名称的列表,用冒号分隔。以下示例显示了由冒号分隔的两个密码名称:For greatest portability, the cipher list should be a list of one or more cipher names, separated by colons. The following example shows two cipher names separated by a colon:

    [mysqld]
    ssl_cipher="DHE-RSA-AES128-GCM-SHA256:AES128-SHA"
    

    OpenSSL 支持在 OpenSSL 文档中描述的指定密码的语法,见 https://www.openssl.org/docs/manmaster/man1/ciphers.html。OpenSSL supports the syntax for specifying ciphers described in the OpenSSL documentation at https://www.openssl.org/docs/manmaster/man1/ciphers.html.

    有关 MySQL 支持的加密密码的信息,请参阅 第 8.3.2 节,“加密连接 TLS 协议和密码”。For information about which encryption ciphers MySQL supports, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.

    此变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 之后或在变量值已被持久化情况下重启后为新建立的连接使用的 TLS 上下文。请参阅 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_crl

    命令行格式Command-Line Format --ssl-crl=file_name--ssl-crl=file_name
    系统变量System Variable ssl_crl
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    包含 PEM 格式证书吊销列表的文件的路径名。The path name of the file containing certificate revocation lists in PEM format.

    此变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 之后或在变量值已被持久化情况下重启后为新建立的连接使用的 TLS 上下文。请参阅 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_crlpath

    命令行格式Command-Line Format --ssl-crlpath=dir_name--ssl-crlpath=dir_name
    系统变量System Variable ssl_crlpath
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name
    默认值Default Value NULL

    包含 PEM 格式证书吊销列表文件的目录路径。The path of the directory that contains certificate revocation-list files in PEM format.

    此变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 之后或在变量值已被持久化情况下重启后为新建立的连接使用的 TLS 上下文。请参阅 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_fips_mode

    命令行格式Command-Line Format --ssl-fips-mode={OFF|ON|STRICT}--ssl-fips-mode={OFF|ON|STRICT}
    已弃用Deprecated 是Yes
    系统变量System Variable ssl_fips_mode
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value OFFOFF
    有效值Valid Values

    OFF(或 0)OFF (or 0)

    ON(或 1)ON (or 1)

    STRICT(或 2)STRICT (or 2)

    控制是否在服务器端启用 FIPS 模式。ssl_fips_mode 系统变量与其他 ssl_xxx 系统变量不同,它不是用于控制服务器是否允许加密连接,而是用于影响允许哪些加密操作。详见 第 8.8 节,“FIPS 支持”。Controls whether to enable FIPS mode on the server side. The ssl_fips_mode system variable differs from other ssl_xxx system variables in that it is not used to control whether the server permits encrypted connections, but rather to affect which cryptographic operations are permitted. See Section 8.8, “FIPS Support”.

    允许的 ssl_fips_mode 值如下:These ssl_fips_mode values are permitted:

    • OFF(或 0):禁用 FIPS 模式。OFF (or 0): Disable FIPS mode.

    • ON(或 1):启用 FIPS 模式。ON (or 1): Enable FIPS mode.

    • STRICT(或 2):启用“strict” FIPS 模式。STRICT (or 2): Enable “strict” FIPS mode.

    Note

    如果 OpenSSL FIPS 对象模块不可用,ssl_fips_mode 唯一允许的值是 OFF。在这种情况下,如果在启动时将 ssl_fips_mode 设置为 ON 或 STRICT,服务器将显示错误消息并退出。If the OpenSSL FIPS Object Module is not available, the only permitted value for ssl_fips_mode is OFF. In this case, setting ssl_fips_mode to ON or STRICT at startup causes the server to produce an error message and exit.

    此选项已被弃用并设为只读。预计将在 MySQL 的未来版本中移除。This option is deprecated and made read-only. Expect it to be removed in a future version of MySQL.

  • ssl_key

    命令行格式Command-Line Format --ssl-key=file_name--ssl-key=file_name
    系统变量System Variable ssl_key
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 文件名File name
    默认值Default Value NULL

    服务器 SSL 私钥文件的路径名,文件格式为 PEM。为了更好的安全性,请使用 RSA 密钥大小至少为 2048 位的证书。The path name of the server SSL private key file in PEM format. For better security, use a certificate with an RSA key size of at least 2048 bits.

    如果密钥文件受密码保护,服务器会提示用户输入密码。密码必须以交互方式提供;不能存储在文件中。如果密码不正确,程序将继续运行,就好像无法读取密钥一样。If the key file is protected by a passphrase, the server prompts the user for the passphrase. The password must be given interactively; it cannot be stored in a file. If the passphrase is incorrect, the program continues as if it could not read the key.

    此变量可以在运行时修改,以影响服务器在执行 ALTER INSTANCE RELOAD TLS 之后或在变量值已被持久化情况下重启后为新建立的连接使用的 TLS 上下文。请参阅 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections established after the execution of ALTER INSTANCE RELOAD TLS or after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

  • ssl_session_cache_mode

    命令行格式Command-Line Format --ssl_session_cache_mode={ON|OFF}
    系统变量System Variable ssl_session_cache_mode
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON
    有效值Valid Values

    ONON

    OFFOFF

    控制是否在服务器端启用会话缓存内存以及服务器生成会话票据。默认模式是ON(启用会话缓存模式)。对ssl_session_cache_mode系统变量的更改,仅在执行ALTER INSTANCE RELOAD TLS语句后生效,或者如果变量值已持久化,则在重启后生效。Controls whether to enable the session cache in memory on the server side and session-ticket generation by the server. The default mode is ON (enable session cache mode). A change to the ssl_session_cache_mode system variable has an effect only after the ALTER INSTANCE RELOAD TLS statement has been executed, or after a restart if the variable value was persisted.

    允许的ssl_session_cache_mode值如下:These ssl_session_cache_mode values are permitted:

    • ON:启用会话缓存模式。ON: Enable session cache mode.

    • OFF:禁用会话缓存模式。OFF: Disable session cache mode.

    如果此系统变量的值为 OFF,服务器不会宣传其对会话恢复的支持。在运行 OpenSSL 1.0.x 时,会话票据始终会生成,但在启用 ssl_session_cache_mode 时,这些票据不可用。The server does not advertise its support for session resumption if the value of this system variable is OFF. When running on OpenSSL 1.0.x the session tickets are always generated, but the tickets are not usable when ssl_session_cache_mode is enabled.

    当前 ssl_session_cache_mode 的生效值可以通过 Ssl_session_cache_mode 状态变量进行观察。The current value in effect for ssl_session_cache_mode can be observed with the Ssl_session_cache_mode status variable.

  • ssl_session_cache_timeout

    命令行格式Command-Line Format --ssl_session_cache_timeout
    系统变量System Variable ssl_session_cache_timeout
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 300
    最小值Minimum Value 0
    最大值Maximum Value 84600
    单位Unit 秒seconds

    设置在建立新的加密连接到服务器时允许重用先前会话的时间段,前提是启用了ssl_session_cache_mode系统变量并且先前会话数据可用。如果会话超时已到期,则无法再重用该会话。Sets a period of time during which prior session reuse is permitted when establishing a new encrypted connection to the server, provided the ssl_session_cache_mode system variable is enabled and prior session data is available. If the session timeout expires, a session can no longer be reused.

    默认值为 300 秒,最大值为 84600 秒(即一天的秒数)。对ssl_session_cache_timeout系统变量的更改仅在执行ALTER INSTANCE RELOAD TLS语句后生效,或者如果变量值已持久化,则在重启后生效。当前生效的ssl_session_cache_timeout值可以通过Ssl_session_cache_timeout状态变量观察到。The default value is 300 seconds and the maximum value is 84600 (or one day in seconds). A change to the ssl_session_cache_timeout system variable has an effect only after the ALTER INSTANCE RELOAD TLS statement has been executed, or after a restart if the variable value was persisted. The current value in effect for ssl_session_cache_timeout can be observed with the Ssl_session_cache_timeout status variable.

  • statement_id

    系统变量System Variable statement_id
    范围Scope 会议Session
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer

    当前会话中执行的每条语句都会分配一个序列号。可以将其与 session_track_system_variables 系统变量一起使用,以便在性能模式表中识别该语句,例如 events_statements_history 表。Each statement executed in the current session is assigned a sequence number. This can be used together with the session_track_system_variables system variable to identify this statement in Performance Schema tables such as the events_statements_history table.

  • stored_program_cache

    命令行格式Command-Line Format --stored-program-cache=#
    系统变量System Variable stored_program_cache
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 256
    最小值Minimum Value 16
    最大值Maximum Value 524288

    为每个连接设置缓存存储例程数量的软上限。该变量的值是以 MySQL 服务器为存储过程和存储函数分别维护的两个缓存中存储例程的数量来指定的。Sets a soft upper limit for the number of cached stored routines per connection. The value of this variable is specified in terms of the number of stored routines held in each of the two caches maintained by the MySQL Server for, respectively, stored procedures and stored functions.

    每当执行存储例程时,会在解析例程中的第一个或顶层语句之前检查此缓存大小;如果相同类型的例程(根据正在执行的是存储过程还是存储函数)数量超过此变量指定的限制,则相应的缓存将被清空,之前为缓存对象分配的内存将被释放。这允许即使在存储例程之间存在依赖关系时,也能安全地清空缓存。Whenever a stored routine is executed this cache size is checked before the first or top-level statement in the routine is parsed; if the number of routines of the same type (stored procedures or stored functions according to which is being executed) exceeds the limit specified by this variable, the corresponding cache is flushed and memory previously allocated for cached objects is freed. This allows the cache to be flushed safely, even when there are dependencies between stored routines.

    存储过程缓存和存储函数缓存与字典对象缓存的存储程序定义缓存分区并行存在。存储过程缓存和存储函数缓存是每个连接独有的,而存储程序定义缓存是共享的。存储过程和存储函数缓存中的对象存在与存储程序定义缓存中的对象存在没有依赖关系,反之亦然。有关更多信息,请参见16.4 节,“字典对象缓存”。The stored procedure and stored function caches exists in parallel with the stored program definition cache partition of the dictionary object cache. The stored procedure and stored function caches are per connection, while the stored program definition cache is shared. The existence of objects in the stored procedure and stored function caches have no dependence on the existence of objects in the stored program definition cache, and vice versa. For more information, see Section 16.4, “Dictionary Object Cache”.

  • stored_program_definition_cache

    命令行格式Command-Line Format --stored-program-definition-cache=#
    系统变量System Variable stored_program_definition_cache
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 256
    最小值Minimum Value 256
    最大值Maximum Value 524288

    定义可保存在字典对象缓存中的存储程序定义对象(包括已使用和未使用)的数量上限。Defines a limit for the number of stored program definition objects, both used and unused, that can be kept in the dictionary object cache.

    仅当正在使用的存储程序定义对象数量少于 stored_program_definition_cache 定义的容量时,未使用的存储程序定义对象才会保存在字典对象缓存中。Unused stored program definition objects are only kept in the dictionary object cache when the number in use is less than the capacity defined by stored_program_definition_cache.

    设置为 0 意味着存储程序定义对象仅在使用时保存在字典对象缓存中。A setting of 0 means that stored program definition objects are only kept in the dictionary object cache while they are in use.

    存储程序定义缓存分区与使用 stored_program_cache 选项配置的存储过程缓存和存储函数缓存并行存在。The stored program definition cache partition exists in parallel with the stored procedure and stored function caches that are configured using the stored_program_cache option.

    stored_program_cache 选项为每个连接缓存的存储过程或函数的数量设置一个软上限,并且每次连接执行存储过程或函数时都会检查该限制。而存储程序定义缓存分区则是一个共享缓存,用于存储其他用途的存储程序定义对象。存储程序定义缓存分区中对象的存在与存储过程缓存或存储函数缓存中对象的存在相互独立,反之亦然。The stored_program_cache option sets a soft upper limit for the number of cached stored procedures or functions per connection, and the limit is checked each time a connection executes a stored procedure or function. The stored program definition cache partition, on the other hand, is a shared cache that stores stored program definition objects for other purposes. The existence of objects in the stored program definition cache partition has no dependence on the existence of objects in the stored procedure cache or stored function cache, and vice versa.

    有关相关信息,请参见 第 16.4 节,“字典对象缓存”。For related information, see Section 16.4, “Dictionary Object Cache”.

  • super_read_only

    命令行格式Command-Line Format --super-read-only[={OFF|ON}]
    系统变量System Variable super_read_only
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    如果read_only 系统变量已启用,服务器不允许任何客户端更新,除非是拥有CONNECTION_ADMIN 权限(或已弃用的 SUPER 权限)的用户。如果super_read_only 系统变量也已启用,服务器甚至禁止拥有CONNECTION_ADMIN 或 SUPER 用户的客户端更新。有关只读模式的描述以及 read_only 与 super_read_only 如何交互的信息,请参阅 read_only 系统变量的描述。If the read_only system variable is enabled, the server permits no client updates except from users who have the CONNECTION_ADMIN privilege (or the deprecated SUPER privilege). If the super_read_only system variable is also enabled, the server prohibits client updates even from users who have CONNECTION_ADMIN or SUPER. See the description of the read_only system variable for a description of read-only mode and information about how read_only and super_read_only interact.

    当启用 super_read_only 时,客户端更新被阻止的操作包括那些不一定看起来像更新的操作,例如 CREATE FUNCTION(用于安装可加载函数)、INSTALL PLUGIN 和 INSTALL COMPONENT。这些操作被禁止,因为它们涉及对 mysql 系统架构中的表进行更改。Client updates prevented when super_read_only is enabled include operations that do not necessarily appear to be updates, such as CREATE FUNCTION (to install a loadable function), INSTALL PLUGIN, and INSTALL COMPONENT. These operations are prohibited because they involve changes to tables in the mysql system schema.

    同样,如果事件调度器已启用,启用 super_read_only 系统变量将阻止其更新 events 数据字典表中的事件 “最后执行时间”。这会导致事件调度器在下一次尝试执行计划事件时停止,并在写入服务器错误日志后停止。(在这种情况下,event_scheduler 系统变量不会从 ON 变为 OFF。其含义是,该变量会拒绝 DBA 对事件调度器启用或禁用的 意图,而事件调度器实际的启动或停止状态可能不同。)如果在启用之后随后禁用 super_read_only,服务器会根据需要自动重新启动事件调度器。Similarly, if the Event Scheduler is enabled, enabling the super_read_only system variable prevents it from updating event “last executed” timestamps in the events data dictionary table. This causes the Event Scheduler to stop the next time it tries to execute a scheduled event, after writing a message to the server error log. (In this situation the event_scheduler system variable does not change from ON to OFF. An implication is that this variable rejects the DBA intent that the Event Scheduler be enabled or disabled, where its actual status of started or stopped may be distinct.). If super_read_only is subsequently disabled after being enabled, the server automatically restarts the Event Scheduler as needed.

    对复制源服务器上的super_read_only所做的更改不会复制到副本服务器。该值可以在副本上独立设置,而不受源服务器设置的影响。Changes to super_read_only on a replication source server are not replicated to replica servers. The value can be set on a replica independent of the setting on the source.

  • syseventlog.facility

    命令行格式Command-Line Format --syseventlog.facility=value--syseventlog.facility=value
    系统变量System Variable syseventlog.facility
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value daemon

    将错误日志输出到 syslog 的功能(发送消息的程序类型)。除非安装了 log_sink_syseventlog 错误日志组件,否则该变量不可用。请参见 第 7.4.2.8 节,“将错误日志记录到系统日志”。The facility for error log output written to syslog (what type of program is sending the message). This variable is unavailable unless the log_sink_syseventlog error log component is installed. See Section 7.4.2.8, “Error Logging to the System Log”.

    允许的值可能因操作系统而异;请查阅系统 syslog 文档。The permitted values can vary per operating system; consult your system syslog documentation.

    该变量在 Windows 上不存在。This variable does not exist on Windows.

  • syseventlog.include_pid

    命令行格式Command-Line Format --syseventlog.include-pid[={OFF|ON}]
    系统变量System Variable syseventlog.include_pid
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    是否在写入 syslog 的每行错误日志输出中包含服务器进程 ID。除非安装了 log_sink_syseventlog 错误日志组件,否则该变量不可用。请参阅 第 7.4.2.8 节,“记录错误到系统日志”。Whether to include the server process ID in each line of error log output written to syslog. This variable is unavailable unless the log_sink_syseventlog error log component is installed. See Section 7.4.2.8, “Error Logging to the System Log”.

    该变量在 Windows 上不存在。This variable does not exist on Windows.

  • syseventlog.tag

    命令行格式Command-Line Format --syseventlog.tag=tag
    系统变量System Variable syseventlog.tag
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value empty stringempty string

    要添加到写入 syslog 或 Windows 事件日志的错误日志输出中的服务器标识符的标签。除非安装了 log_sink_syseventlog 错误日志组件,否则此变量不可用。请参阅 第 7.4.2.8 节,“错误日志记录到系统日志”。The tag to be added to the server identifier in error log output written to syslog or the Windows Event Log. This variable is unavailable unless the log_sink_syseventlog error log component is installed. See Section 7.4.2.8, “Error Logging to the System Log”.

    默认情况下,不会设置任何标签,因此服务器标识在 Windows 上只是 MySQL,在其他平台上是 mysqld。如果指定了标签值 tag,它将附加到服务器标识后面,前面带一个连字符,从而生成 syslog 标识为 mysqld-tag(在 Windows 上为 MySQL-tag)。By default, no tag is set, so the server identifier is simply MySQL on Windows, and mysqld on other platforms. If a tag value of tag is specified, it is appended to the server identifier with a leading hyphen, resulting in a syslog identifier of mysqld-tag (or MySQL-tag on Windows).

    在 Windows 上,要使用尚不存在的标签,必须以具有管理员权限的帐户运行服务器,以允许创建该标签的注册表项。如果标签已经存在,则不需要提升权限。On Windows, to use a tag that does not already exist, the server must be run from an account with Administrator privileges, to permit creation of a registry entry for the tag. Elevated privileges are not required if the tag already exists.

  • system_time_zone system_time_zone

    系统变量System Variable system_time_zonesystem_time_zone
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    服务器系统时区。当服务器开始执行时,它会从机器默认设置继承时区设置,可能会根据用于运行服务器的账户环境或启动脚本进行修改。该值用于设置 system_time_zone。要明确指定系统时区,请设置 TZ 环境变量或使用 --timezone 选项启动 mysqld_safe 脚本。The server system time zone. When the server begins executing, it inherits a time zone setting from the machine defaults, possibly modified by the environment of the account used for running the server or the startup script. The value is used to set system_time_zone. To explicitly specify the system time zone, set the TZ environment variable or use the --timezone option of the mysqld_safe script.

    除了启动时初始化之外,如果服务器主机的时区发生变化(例如,由于夏令时),system_time_zone会反映该变化,这对应用程序有以下影响:In addition to startup time initialization, if the server host time zone changes (for example, due to daylight saving time), system_time_zone reflects that change, which has these implications for applications:

    • 引用system_time_zone的查询在夏令时改变前会得到一个值,而在改变后会得到另一个值。Queries that reference system_time_zone will get one value before a daylight saving change and a different value after the change.

    • 对于在夏令时改变前开始执行、在改变后结束的查询,system_time_zone在查询内保持不变,因为该值通常在执行开始时被缓存。For queries that begin executing before a daylight saving change and end after the change, the system_time_zone remains constant within the query because the value is usually cached at the beginning of execution.

    system_time_zone 变量与 time_zone 变量不同。虽然它们可能有相同的值,但后者变量用于初始化每个连接的客户端的时区。请参见 第 7.1.15 节,“MySQL 服务器时区支持”。The system_time_zone variable differs from the time_zone variable. Although they might have the same value, the latter variable is used to initialize the time zone for each client that connects. See Section 7.1.15, “MySQL Server Time Zone Support”.

  • table_definition_cache

    命令行格式Command-Line Format --table-definition-cache=#
    系统变量System Variable table_definition_cache
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1 (signifies autosizing; do not assign this literal value)
    最小值Minimum Value 400
    最大值Maximum Value 524288

    表定义缓存中可以存储的表定义数量。如果使用大量表,可以创建一个大的表定义缓存以加快表的打开速度。与普通表缓存不同,表定义缓存占用空间较少,并且不使用文件描述符。最小值为 400。默认值基于以下公式,并限制在 2000:The number of table definitions that can be stored in the table definition cache. If you use a large number of tables, you can create a large table definition cache to speed up opening of tables. The table definition cache takes less space and does not use file descriptors, unlike the normal table cache. The minimum value is 400. The default value is based on the following formula, capped to a limit of 2000:

    MIN(400 + table_open_cache / 2, 2000)
    

    对于InnoDB,table_definition_cache 设置作为字典对象缓存中表实例数量以及一次可以打开的每表文件表空间数量的软限制。For InnoDB, the table_definition_cache setting acts as a soft limit for the number of table instances in the dictionary object cache and the number file-per-table tablespaces that can be open at one time.

    如果字典对象缓存中的表实例数量超过 table_definition_cache 限制,将会启动 LRU 机制来标记表实例以进行驱逐,并最终将它们从字典对象缓存中移除。具有缓存元数据的打开表数量可能高于 table_definition_cache 限制,这是因为具有外键关系的表实例不会被放置在 LRU 列表中。If the number of table instances in the dictionary object cache exceeds the table_definition_cache limit, an LRU mechanism begins marking table instances for eviction and eventually removes them from the dictionary object cache. The number of open tables with cached metadata can be higher than the table_definition_cache limit due to table instances with foreign key relationships, which are not placed on the LRU list.

    一次可以打开的每表文件表空间的数量受table_definition_cache和innodb_open_files设置的限制。如果两个变量都设置了,则使用更高的设置。如果两个变量都没有设置,则使用默认值更高的table_definition_cache设置。如果打开的表空间数量超过table_definition_cache或innodb_open_files定义的限制,一个 LRU 机制会在 LRU 列表中搜索已完全刷新且当前未被扩展的表空间文件。每次打开新表空间时都会执行此过程。只有非活动的表空间会被关闭。The number of file-per-table tablespaces that can be open at one time is limited by both the table_definition_cache and innodb_open_files settings. If both variables are set, the highest setting is used. If neither variable is set, the table_definition_cache setting, which has a higher default value, is used. If the number of open tablespaces exceeds the limit defined by table_definition_cache or innodb_open_files, an LRU mechanism searches the LRU list for tablespace files that are fully flushed and not currently being extended. This process is performed each time a new tablespace is opened. Only inactive tablespaces are closed.

    表定义缓存与字典对象缓存的表定义缓存分区并行存在。两个缓存都存储表定义,但服务于 MySQL 服务器的不同部分。一个缓存中的对象与另一个缓存中对象的存在没有依赖关系。更多信息,请参见 第 16.4 节,“字典对象缓存”。The table definition cache exists in parallel with the table definition cache partition of the dictionary object cache. Both caches store table definitions but serve different parts of the MySQL server. Objects in one cache have no dependence on the existence of objects in the other. For more information, see Section 16.4, “Dictionary Object Cache”.

  • table_encryption_privilege_check

    命令行格式Command-Line Format --table-encryption-privilege-check[={OFF|ON}]
    系统变量System Variable table_encryption_privilege_check
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    控制在创建或修改具有与default_table_encryption设置不同的加密模式的模式或通用表空间时,或者在创建或修改具有不同于默认模式加密设置的表时发生的TABLE_ENCRYPTION_ADMIN权限检查。该检查默认情况下为禁用。Controls the TABLE_ENCRYPTION_ADMIN privilege check that occurs when creating or altering a schema or general tablespace with encryption that differs from the default_table_encryption setting, or when creating or altering a table with an encryption setting that differs from the default schema encryption. The check is disabled by default.

    在运行时设置 table_encryption_privilege_check 需要 SUPER 权限。Setting table_encryption_privilege_check at runtime requires the SUPER privilege.

    table_encryption_privilege_check 支持 SET PERSIST 和 SET PERSIST_ONLY 语法。详见 第 7.1.9.3 节,“持久化系统变量”。table_encryption_privilege_check supports SET PERSIST and SET PERSIST_ONLY syntax. See Section 7.1.9.3, “Persisted System Variables”.

    更多信息,请参见 为模式和通用表空间定义加密默认值。For more information, see Defining an Encryption Default for Schemas and General Tablespaces.

  • table_open_cache

    命令行格式Command-Line Format --table-open-cache=#
    系统变量System Variable table_open_cache
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 4000
    最小值Minimum Value 1
    最大值Maximum Value 524288

    所有线程的打开表的数量。增加此值会增加mysqld所需的文件描述符数量。open_files_limit - 10 -该变量的有效值是max_connections / 2的有效值、The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. The effective value of this variable is the greater of the effective value of open_files_limit - 10 - the effective value of max_connections / 2, and 400; that is

    MAX(
        (open_files_limit - 10 - max_connections) / 2,
        400
       )
    

    您可以通过检查 Opened_tables 状态变量来判断是否需要增加表缓存。如果 Opened_tables 的值很大,并且您不经常使用 FLUSH TABLES(它只是强制关闭并重新打开所有表),那么您应该增加 table_open_cache 变量的值。有关表缓存的更多信息,请参阅 第 10.4.3.1 节,“MySQL 如何打开和关闭表”。You can check whether you need to increase the table cache by checking the Opened_tables status variable. If the value of Opened_tables is large and you do not use FLUSH TABLES often (which just forces all tables to be closed and reopened), then you should increase the value of the table_open_cache variable. For more information about the table cache, see Section 10.4.3.1, “How MySQL Opens and Closes Tables”.

  • table_open_cache_instances

    命令行格式Command-Line Format --table-open-cache-instances=#
    系统变量System Variable table_open_cache_instances
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 16
    最小值Minimum Value 1
    最大值Maximum Value 64

    打开表缓存实例的数量。为了通过减少会话之间的争用来提高可扩展性,打开表缓存可以划分为几个较小的缓存实例,大小为 table_open_cache / table_open_cache_instances。会话只需要锁定一个实例即可访问其 DML 语句。这将缓存访问在实例之间进行分段,从而在有许多会话访问表时允许更高性能的操作。(DDL 语句仍然需要锁定整个缓存,但此类语句的频率远低于 DML 语句。)The number of open tables cache instances. To improve scalability by reducing contention among sessions, the open tables cache can be partitioned into several smaller cache instances of size table_open_cache / table_open_cache_instances . A session needs to lock only one instance to access it for DML statements. This segments cache access among instances, permitting higher performance for operations that use the cache when there are many sessions accessing tables. (DDL statements still require a lock on the entire cache, but such statements are much less frequent than DML statements.)

    对于经常使用 16 个或更多核心的系统,推荐使用 8 或 16 的值。然而,如果你的表上有许多大型触发器导致高内存负载,table_open_cache_instances 的默认设置可能会导致过高的内存使用。在这种情况下,将 table_open_cache_instances 设置为 1 可能有助于限制内存使用。A value of 8 or 16 is recommended on systems that routinely use 16 or more cores. However, if you have many large triggers on your tables that cause a high memory load, the default setting for table_open_cache_instances might lead to excessive memory usage. In that situation, it can be helpful to set table_open_cache_instances to 1 in order to restrict memory usage.

  • tablespace_definition_cache

    命令行格式Command-Line Format --tablespace-definition-cache=#
    系统变量System Variable tablespace_definition_cache
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 256
    最小值Minimum Value 256
    最大值Maximum Value 524288

    定义可以保存在字典对象缓存中的表空间定义对象的数量限制,包括已使用和未使用的对象。Defines a limit for the number of tablespace definition objects, both used and unused, that can be kept in the dictionary object cache.

    未使用的表空间定义对象仅在使用中的数量小于 tablespace_definition_cache 定义的容量时,才会保存在字典对象缓存中。Unused tablespace definition objects are only kept in the dictionary object cache when the number in use is less than the capacity defined by tablespace_definition_cache.

    设置为 0 意味着表空间定义对象仅在使用时保存在字典对象缓存中。A setting of 0 means that tablespace definition objects are only kept in the dictionary object cache while they are in use.

    欲了解更多信息,请参见 第 16.4 节,“字典对象缓存”。For more information, see Section 16.4, “Dictionary Object Cache”.

  • temptable_max_mmap

    命令行格式Command-Line Format --temptable-max-mmap=#
    系统变量System Variable temptable_max_mmap
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 2^64-1
    单位Unit 字节bytes

    定义在 TempTable 存储引擎开始将数据存入 InnoDB 内部临时表到磁盘之前,允许从内存映射临时文件分配的最大内存量(以字节为单位)。设置为 0(默认值)会禁用从内存映射临时文件分配内存。有关更多信息,请参见 第 10.4.4 节,“MySQL 中的内部临时表使用”。Defines the maximum amount of memory (in bytes) the TempTable storage engine is permitted to allocate from memory-mapped temporary files before it starts storing data to InnoDB internal temporary tables on disk. A setting of 0 (default) disables allocation of memory from memory-mapped temporary files. For more information, see Section 10.4.4, “Internal Temporary Table Use in MySQL”.

    在 MySQL 8.4 之前,此选项的默认值为 1 GiB,而不是 0。Before MySQL 8.4, this option was set to 1 GiB instead of 0.

  • temptable_max_ram

    命令行格式Command-Line Format --temptable-max-ram=#
    系统变量System Variable temptable_max_ram
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 3% of total memory: min 1 GB, max 4 GB3% of total memory: min 1 GB, max 4 GB
    最小值Minimum Value 2097152
    最大值Maximum Value 2^64-1
    单位Unit 字节bytes

    定义 TempTable 存储引擎在开始将数据存储到磁盘之前可以占用的最大内存量。默认值为服务器总内存的 3%,最小和最大默认值范围为 1-4 GiB。有关更多信息,请参见 第 10.4.4 节,“MySQL 中内部临时表的使用”。Defines the maximum amount of memory that can be occupied by the TempTable storage engine before it starts storing data on disk. The default value is 3% of total memory available on the server, with a minimum and maximum default range of 1-4 GiB. For more information, see Section 10.4.4, “Internal Temporary Table Use in MySQL”.

    在 MySQL 8.4 之前,默认值始终为 1 GiB。Before MySQL 8.4, the default value was always 1 GiB.

  • temptable_use_mmap

    命令行格式Command-Line Format --temptable-use-mmap[={OFF|ON}]
    已弃用Deprecated 是Yes
    系统变量System Variable temptable_use_mmap
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    定义当 TempTable 存储引擎占用的内存超过 temptable_max_ram 变量定义的限制时,是否将内部内存临时表分配为空间映射临时文件。当 temptable_use_mmap 被禁用(默认)时,TempTable 存储引擎改用 InnoDB 磁盘内部临时表。有关更多信息,请参见 第 10.4.4 节,“MySQL 中的内部临时表使用”。Defines whether the TempTable storage engine allocates space for internal in-memory temporary tables as memory-mapped temporary files when the amount of memory occupied by the TempTable storage engine exceeds the limit defined by the temptable_max_ram variable. When temptable_use_mmap is disabled (default), the TempTable storage engine uses InnoDB on-disk internal temporary tables instead. For more information, see Section 10.4.4, “Internal Temporary Table Use in MySQL”.

  • thread_cache_size thread_cache_size

    命令行格式Command-Line Format --thread-cache-size=#--thread-cache-size=#
    系统变量System Variable thread_cache_sizethread_cache_size
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1 (signifies autosizing; do not assign this literal value)
    最小值Minimum Value 0
    最大值Maximum Value 16384

    服务器应缓存多少线程以供重用。当客户端断开连接时,如果缓存中的线程少于 thread_cache_size,客户端的线程将被放入缓存。线程的请求将尽可能通过重用缓存中的线程来满足,只有当缓存为空时才会创建新线程。如果有大量新连接,可以增加此变量以提高性能。通常,如果线程实现良好,这不会带来显著的性能提升。然而,如果您的服务器每秒处理数百个连接,通常应将 thread_cache_size 设置得足够高,以便大多数新连接使用缓存线程。通过检查 Connections 与 Threads_created 状态变量之间的差异,可以了解线程缓存的效率。详情请参见 第 7.1.10 节,“服务器状态变量”。How many threads the server should cache for reuse. When a client disconnects, the client's threads are put in the cache if there are fewer than thread_cache_size threads there. Requests for threads are satisfied by reusing threads taken from the cache if possible, and only when the cache is empty is a new thread created. This variable can be increased to improve performance if you have a lot of new connections. Normally, this does not provide a notable performance improvement if you have a good thread implementation. However, if your server sees hundreds of connections per second you should normally set thread_cache_size high enough so that most new connections use cached threads. By examining the difference between the Connections and Threads_created status variables, you can see how efficient the thread cache is. For details, see Section 7.1.10, “Server Status Variables”.

    默认值基于以下公式,最大值限制为 100:The default value is based on the following formula, capped to a limit of 100:

    8 + (max_connections / 100)
    
  • thread_handling

    命令行格式Command-Line Format --thread-handling=name
    系统变量System Variable thread_handling
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value one-thread-per-connectionone-thread-per-connection
    有效值Valid Values

    no-threadsno-threads

    one-thread-per-connectionone-thread-per-connection

    loaded-dynamicallyloaded-dynamically

    服务器用于连接线程的线程处理模型。允许的值有 no-threads(服务器使用单线程处理一个连接)、one-thread-per-connection(服务器为每个客户端连接使用一个线程)以及 loaded-dynamically(由线程池插件在初始化时设置)。no-threads 在 Linux 下调试时非常有用;参见 第 7.9 节,“调试 MySQL”。The thread-handling model used by the server for connection threads. The permissible values are no-threads (the server uses a single thread to handle one connection), one-thread-per-connection (the server uses one thread to handle each client connection), and loaded-dynamically (set by the thread pool plugin when it initializes). no-threads is useful for debugging under Linux; see Section 7.9, “Debugging MySQL”.

  • thread_pool_algorithm

    命令行格式Command-Line Format --thread-pool-algorithm=#
    系统变量System Variable thread_pool_algorithm
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 1

    此变量控制线程池插件使用的算法:This variable controls which algorithm the thread pool plugin uses:

    • 0:使用保守的低并发算法。0: Use a conservative low-concurrency algorithm.

    • 1:使用激进的高并发算法,在最优线程数下性能更好,但如果连接数达到极高值,性能可能会下降。1: Use an aggressive high-currency algorithm which performs better with optimal thread counts, but performance may be degraded if the number of connections reaches extremely high values.

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_dedicated_listeners

    命令行格式Command-Line Format --thread-pool-dedicated-listeners
    系统变量System Variable thread_pool_dedicated_listeners
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    为每个线程组专门分配一个监听线程,以监听分配给该组的连接发出的语句。Dedicates a listener thread in each thread group to listen for incoming statements from connections assigned to the group.

    • OFF:(默认)禁用专用监听线程。OFF: (Default) Disables dedicated listener threads.

    • ON:为每个线程组专门分配一个监听线程,以监听分配给该组的连接发出的语句。专用监听线程不执行查询。ON: Dedicates a listener thread in each thread group to listen for incoming statements from connections assigned to the group. Dedicated listener threads do not execute queries.

    启用 thread_pool_dedicated_listeners 只有在通过 thread_pool_max_transactions_limit 定义了事务限制时才有用。否则,不应启用 thread_pool_dedicated_listeners。Enabling thread_pool_dedicated_listeners is only useful when a transaction limit is defined by thread_pool_max_transactions_limit. Otherwise, thread_pool_dedicated_listeners should not be enabled.

    此变量仅在 MySQL 企业版中可用,并且在 MySQL 8.4 中不受支持。This variable is available only with MySQL Enterprise Edition, and not supported in MySQL 8.4.

  • thread_pool_high_priority_connection

    命令行格式Command-Line Format --thread-pool-high-priority-connection=#
    系统变量System Variable thread_pool_high_priority_connection
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 1

    此变量影响执行前新语句的排队。如果值为 0(false,默认值),语句排队会使用低优先级队列和高优先级队列。如果值为 1(true),排队语句总是进入高优先级队列。This variable affects queuing of new statements prior to execution. If the value is 0 (false, the default), statement queuing uses both the low-priority and high-priority queues. If the value is 1 (true), queued statements always go to the high-priority queue.

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_longrun_trx_limit

    命令行格式Command-Line Format --thread-pool-longrun-trx-limit=#
    系统变量System Variable thread_pool_longrun_trx_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 2000
    最小值Minimum Value 10
    最大值Maximum Value 60*60*24
    单位Unit 毫秒ms

    当thread_pool_max_transactions_limit 被使用时,每个线程组中可以同时活动的事务数量是有限的。如果所有可用数量都被长时间运行的事务占用,则分配给该组的任何额外事务都会被阻塞,直到其中一个长时间运行的事务完成,这会让用户感到无法理解的卡顿。When thread_pool_max_transactions_limit is in use, there is a maximum number of transactions that can be active in each thread group. If entire number available is being used by long-running transactions, any additional transaction assigned to the group blocks until one of the long-running transactions is completed, which users can perceive as an inexplicable hang.

    为缓解此问题,如果所有使用事务最大值的线程执行时间都超过了由 thread_pool_longrun_trx_limit 指定的间隔(以毫秒为单位),则会暂停给定线程组的限制。当长时间运行的事务数量减少时,thread_pool_max_transactions_limit 可以(并且会)再次启用。为了让这种情况发生,正在进行的事务数量必须少于 thread_pool_max_transactions_limit / 2,具体间隔如以下所示:To mitigate this issue, the limit for a given thread group is suspended if all of the threads using up the transaction maximum have been executing longer than the interval (in milliseconds) specified by thread_pool_longrun_trx_limit. When the number of long-running transactions decreases, thread_pool_max_transactions_limit can be (and is) enabled again. In order for this to happen, the number of ongoing transactions must be less than thread_pool_max_transactions_limit / 2 for the interval defined as shown:

    MIN( MAX(thread_pool_longrun_trx_limit * 15, 5000), 30000)
    

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_max_active_query_threads

    命令行格式Command-Line Format --thread-pool-max-active-query-threads
    系统变量System Variable thread_pool_max_active_query_threads
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 512

    每个组允许的最大活动(运行中)查询线程数。如果值为 0,线程池插件将使用尽可能多的可用线程。The maximum permissible number of active (running) query threads per group. If the value is 0, the thread pool plugin uses up to as many threads as are available.

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_max_transactions_limit

    命令行格式Command-Line Format --thread-pool-max-transactions-limit
    系统变量System Variable thread_pool_max_transactions_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 1000000

    线程池插件允许的最大事务数。定义事务限制会将线程绑定到事务直到其提交,这有助于在高并发情况下稳定吞吐量。The maximum number of transactions permitted by the thread pool plugin. Defining a transaction limit binds a thread to a transaction until it commits, which helps stabilize throughput during high concurrency.

    默认值 0 表示没有事务限制。该变量是动态的,但在运行时不能从 0 更改为更高的值,反之亦然。启动时的非零值允许在运行时进行动态配置。配置 thread_pool_max_transactions_limit 需要 CONNECTION_ADMIN 权限。The default value of 0 means that there is no transaction limit. The variable is dynamic but cannot be changed from 0 to a higher value at runtime and vice versa. A non-zero value at startup permits dynamic configuration at runtime. The CONNECTION_ADMIN privilege is required to configure thread_pool_max_transactions_limit at runtime.

    当您定义事务限制时,启用 thread_pool_dedicated_listeners 会在每个线程组中创建一个专用的监听器线程。额外的专用监听器线程会消耗更多资源并影响线程池性能。因此,应谨慎使用 thread_pool_dedicated_listeners。When you define a transaction limit, enabling thread_pool_dedicated_listeners creates a dedicated listener thread in each thread group. The additional dedicated listener thread consumes more resources and affects thread pool performance. thread_pool_dedicated_listeners should therefore be used cautiously.

    当达到thread_pool_max_transactions_limit定义的限制时,新的连接或现有连接上的事务可能会出现挂起,直到一个或多个现有事务完成。在许多情况下,可以通过设置thread_pool_longrun_trx_limit来缓解此问题,以便在持续一段时间的给定数量的进行中事务达到限制时放宽事务最大值。如果在尝试此操作后,现有连接仍然被阻塞或长时间运行,可能需要使用特权连接访问服务器,以增加限制、移除限制或终止正在运行的事务。请参阅特权连接。When the limit defined by thread_pool_max_transactions_limit has been reached, new connections or transactions on existing connections may appear to hang until one or more existing transactions are completed. It should be possible in many cases to mitigate this issue by setting thread_pool_longrun_trx_limit so that the transaction maximum can be relaxed when the number of ongoing transactions matches it for a given length of time. If existing connections continue to be blocked or long-running even after attempting this, a privileged connection may be required to access the server to increase the limit, remove the limit, or kill running transactions. See Privileged Connections.

    此变量仅在 MySQL 企业版中可用,并且在 MySQL 8.4 中不受支持。This variable is available only with MySQL Enterprise Edition, and not supported in MySQL 8.4.

  • thread_pool_max_unused_threads

    命令行格式Command-Line Format --thread-pool-max-unused-threads=#
    系统变量System Variable thread_pool_max_unused_threads
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 4096

    线程池中允许的最大未使用线程数。该变量可以限制处于休眠状态的线程使用的内存量。The maximum permitted number of unused threads in the thread pool. This variable makes it possible to limit the amount of memory used by sleeping threads.

    值为 0(默认值)表示对休眠线程数量没有限制。值为N,其中N大于 0,意味着 1 个消费者线程和N−1 个备用线程。在这种情况下,如果一个线程准备休眠,但休眠线程数量已达到最大值,该线程将退出而不是进入休眠。A value of 0 (the default) means no limit on the number of sleeping threads. A value of N where N is greater than 0 means 1 consumer thread and N−1 reserve threads. In this case, if a thread is ready to sleep but the number of sleeping threads is already at the maximum, the thread exits rather than going to sleep.

    休眠线程要么作为消费者线程休眠,要么作为备用线程休眠。线程池允许一个线程在休眠时作为消费者线程。如果一个线程进入休眠且没有现有的消费者线程,它将作为消费者线程休眠。当必须唤醒线程时,如果存在消费者线程,则选择消费者线程。只有在没有消费者线程需要唤醒时,才会选择备用线程。A sleeping thread is either sleeping as a consumer thread or a reserve thread. The thread pool permits one thread to be the consumer thread when sleeping. If a thread goes to sleep and there is no existing consumer thread, it sleeps as a consumer thread. When a thread must be woken up, a consumer thread is selected if there is one. A reserve thread is selected only when there is no consumer thread to wake up.

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_prio_kickup_timer

    命令行格式Command-Line Format --thread-pool-prio-kickup-timer=#
    系统变量System Variable thread_pool_prio_kickup_timer
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1000
    最小值Minimum Value 0
    最大值Maximum Value 4294967294
    单位Unit 毫秒milliseconds

    此变量影响在低优先级队列中等待执行的语句。该值表示在等待语句被移至高优先级队列之前的毫秒数。默认值为 1000(1 秒)。This variable affects statements waiting for execution in the low-priority queue. The value is the number of milliseconds before a waiting statement is moved to the high-priority queue. The default is 1000 (1 second).

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_query_threads_per_group

    命令行格式Command-Line Format --thread-pool-query-threads-per-group
    系统变量System Variable thread_pool_query_threads_per_group
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1
    最小值Minimum Value 1
    最大值Maximum Value 4096

    线程组中允许的最大查询线程数。最大值为 4096,但如果设置了 thread_pool_max_transactions_limit,则 thread_pool_query_threads_per_group 不得超过该值。The maximum number of query threads permitted in a thread group. The maximum value is 4096, but if thread_pool_max_transactions_limit is set, thread_pool_query_threads_per_group must not exceed that value.

    默认值 1 表示每个线程组中有一个活动查询线程,这对于许多负载来说工作良好。当您使用高并发线程池算法(thread_pool_algorithm = 1)时,如果由于长时间运行的事务导致响应时间较慢,可以考虑增加该值。The default value of 1 means there is one active query thread in each thread group, which works well for many loads. When you are using the high concurrency thread pool algorithm (thread_pool_algorithm = 1), consider increasing the value if you experience slower response times due to long-running transactions.

    配置 thread_pool_query_threads_per_group 需要 CONNECTION_ADMIN 权限。The CONNECTION_ADMIN privilege is required to configure thread_pool_query_threads_per_group at runtime.

    如果在运行时减少 thread_pool_query_threads_per_group 的值,当前正在运行用户查询的线程将被允许完成,然后移至备用池或被终止。如果在运行时增加该值,并且线程组需要更多线程,这些线程将尽可能从备用池中获取,否则将被创建。If you decrease the value of thread_pool_query_threads_per_group at runtime, threads that are currently running user queries are allowed to complete, then moved to the reserve pool or terminated. if you increment the value at runtime and the thread group needs more threads, these are taken from the reserve pool if possible, otherwise they are created.

    此变量仅在 MySQL 企业版中可用,并且在 MySQL 8.4 中不受支持。This variable is available only with MySQL Enterprise Edition, and not supported in MySQL 8.4.

  • thread_pool_size

    命令行格式Command-Line Format --thread-pool-size=#
    系统变量System Variable thread_pool_size
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 16
    最小值Minimum Value 1
    最大值Maximum Value 512

    线程池中的线程组数量。这是控制线程池性能的最重要参数。它影响可以同时执行的语句数量。如果指定了超出允许范围的值,线程池插件将无法加载,服务器会在错误日志中写入一条消息。The number of thread groups in the thread pool. This is the most important parameter controlling thread pool performance. It affects how many statements can execute simultaneously. If a value outside the range of permissible values is specified, the thread pool plugin does not load and the server writes a message to the error log.

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_stall_limit

    命令行格式Command-Line Format --thread-pool-stall-limit=#
    系统变量System Variable thread_pool_stall_limit
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 6
    最小值Minimum Value 4
    最大值Maximum Value 600
    单位Unit 毫秒 * 10milliseconds * 10

    该变量影响执行语句。其值表示一个语句在开始执行后必须完成的时间量,如果超过该时间,语句将被定义为已停滞,此时线程池允许线程组开始执行另一个语句。该值以 10 毫秒为单位,因此默认值 6 表示 60 毫秒。较短的等待值允许线程更快地启动。较短的值也有助于避免死锁情况。较长的等待值适用于包含长时间运行语句的工作负载,以避免在当前语句执行时启动过多新语句。This variable affects executing statements. The value is the amount of time a statement has to finish after starting to execute before it becomes defined as stalled, at which point the thread pool permits the thread group to begin executing another statement. The value is measured in 10 millisecond units, so the default of 6 means 60ms. Short wait values permit threads to start more quickly. Short values are also better for avoiding deadlock situations. Long wait values are useful for workloads that include long-running statements, to avoid starting too many new statements while the current ones execute.

    仅在启用线程池插件时,此变量才可用。请参阅 第 7.6.3 节,“MySQL 企业线程池”。This variable is available only if the thread pool plugin is enabled. See Section 7.6.3, “MySQL Enterprise Thread Pool”.

  • thread_pool_transaction_delay

    命令行格式Command-Line Format --thread-pool-transaction-delay
    系统变量System Variable thread_pool_transaction_delay
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 0
    最小值Minimum Value 0
    最大值Maximum Value 300000

    在执行新事务之前的延迟时间,单位为毫秒。最大值为 300000(5 分钟)。The delay period before executing a new transaction, in milliseconds. The maximum value is 300000 (5 minutes).

    事务延迟可以在并行事务因资源争用而影响其他操作的性能时使用。例如,如果并行事务影响索引创建或在线缓冲池调整操作,你可以配置事务延迟,以在这些操作运行时减少资源争用。A transaction delay can be used in cases where parallel transactions affect the performance of other operations due to resource contention. For example, if parallel transactions affect index creation or an online buffer pool resizing operation, you can configure a transaction delay to reduce resource contention while those operations are running.

    工作线程在执行新事务之前将按照thread_pool_transaction_delay指定的毫秒数休眠。Worker threads sleep for the number of milliseconds specified by thread_pool_transaction_delay before executing a new transaction.

    thread_pool_transaction_delay 设置不会影响从特权连接(分配到 Admin 线程组的连接)发出的查询。这些查询不受配置的事务延迟影响。The thread_pool_transaction_delay setting does not affect queries issued from a privileged connection (a connection assigned to the Admin thread group). These queries are not subject to a configured transaction delay.

  • thread_stack

    命令行格式Command-Line Format --thread-stack=#
    系统变量System Variable thread_stack
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 1048576
    最小值Minimum Value 131072
    最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709550592
    最大值(32 位平台)Maximum Value (32-bit platforms) 4294966272
    单位Unit 字节bytes
    块大小Block Size 1024

    每个线程的堆栈大小。默认值足够用于正常操作。如果线程堆栈大小过小,会限制服务器能够处理的 SQL 语句复杂度、存储过程的递归深度以及其他消耗内存的操作。The stack size for each thread. The default is large enough for normal operation. If the thread stack size is too small, it limits the complexity of the SQL statements that the server can handle, the recursion depth of stored procedures, and other memory-consuming actions.

  • time_zone time_zone

    系统变量System Variable time_zonetime_zone
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 字符串String
    默认值Default Value SYSTEMSYSTEM
    最小值Minimum Value -13:59
    最大值Maximum Value +14:00

    当前时区。此变量用于初始化每个连接的客户端的时区。默认情况下,其初始值为'SYSTEM'(意味着,“使用 system_time_zone 的值”)。可以在服务器启动时通过 --default-time-zone 选项显式指定此值。参见 第 7.1.15 节,“MySQL 服务器时区支持”。The current time zone. This variable is used to initialize the time zone for each client that connects. By default, the initial value of this is 'SYSTEM' (which means, “use the value of system_time_zone”). The value can be specified explicitly at server startup with the --default-time-zone option. See Section 7.1.15, “MySQL Server Time Zone Support”.

    Note

    如果设置为 SYSTEM,每个需要进行时区计算的 MySQL 函数调用都会调用系统库以确定当前的系统时区。此调用可能受到全局互斥锁保护,从而导致竞争。If set to SYSTEM, every MySQL function call that requires a time zone calculation makes a system library call to determine the current system time zone. This call may be protected by a global mutex, resulting in contention.

  • timestamp

    系统变量System Variable timestamp
    范围Scope 会议Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 数字Numeric
    默认值Default Value UNIX_TIMESTAMP()
    最小值Minimum Value 1
    最大值Maximum Value 2147483647

    为此客户端设置时间。如果使用二进制日志恢复行,则可用于获取原始时间戳。timestamp_value 应为 Unix 纪元时间戳(类似 UNIX_TIMESTAMP() 返回的值),而不是 'YYYY-MM-DD hh:mm:ss' 格式的值,或者为 DEFAULT。Set the time for this client. This is used to get the original timestamp if you use the binary log to restore rows. timestamp_value should be a Unix epoch timestamp (a value like that returned by UNIX_TIMESTAMP(), not a value in 'YYYY-MM-DD hh:mm:ss' format) or DEFAULT.

    将 timestamp 设置为常量值会使其保持该值,直到再次更改。将 timestamp 设置为 DEFAULT 会使其值为访问时的当前日期和时间。Setting timestamp to a constant value causes it to retain that value until it is changed again. Setting timestamp to DEFAULT causes its value to be the current date and time as of the time it is accessed.

    timestamp 是 DOUBLE 类型而不是 BIGINT,因为它的值包含微秒部分。最大值对应 '2038-01-19 03:14:07' UTC,与 TIMESTAMP 数据类型相同。timestamp is a DOUBLE rather than BIGINT because its value includes a microseconds part. The maximum value corresponds to '2038-01-19 03:14:07' UTC, the same as for the TIMESTAMP data type.

    SET timestamp 会影响 NOW() 返回的值,但不会影响 SYSDATE()。这意味着二进制日志中的时间戳设置不会影响 SYSDATE() 的调用。服务器可以使用 --sysdate-is-now 选项启动,使 SYSDATE() 成为 NOW() 的同义词,在这种情况下 SET timestamp 会影响这两个函数。SET timestamp affects the value returned by NOW() but not by SYSDATE(). This means that timestamp settings in the binary log have no effect on invocations of SYSDATE(). The server can be started with the --sysdate-is-now option to cause SYSDATE() to be a synonym for NOW(), in which case SET timestamp affects both functions.

  • tls_certificates_enforced_validation

    命令行格式Command-Line Format --tls-certificates-enforced-validation[={OFF|ON}]
    系统变量System Variable tls_certificates_enforced_validation
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    在启动期间,如果命令行中未给出文件位置,服务器会确保每个所需的 SSL 证书文件的位置存在于默认数据目录中。然而,服务器不会验证证书文件,因此即使证书无效,它也能启动。tls_certificates_enforced_validation 系统变量控制在启动时是否强制进行证书验证。当启用验证强制时,发现无效证书会停止启动执行。默认情况下,证书验证强制是禁用的(OFF)。During startup, the server ensures that the location of each required SSL certificate file is present in the default data directory if the file locations are not given on the command line. However, the server does not validate the certificate files and, as a result, it is able to start with an invalid certificate. The tls_certificates_enforced_validation system variable controls whether certificate validation is enforced at startup. Discovery of an invalid certificate halts the startup execution when validation enforcement is enabled. By default, certificate validation enforcement is disabled (OFF).

    可以通过在命令行上指定 --tls-certificates-enforced-validation 选项来启用验证强制执行,无论是否带有 ON 值。启用验证强制执行后,在通过 ALTER INSTANCE RELOAD TLS 语句重新加载证书时,证书也会被验证。此系统变量不能在重启后保持。有关更多信息,请参阅 配置证书验证强制执行。Validation enforcement can be enabled by specifying the --tls-certificates-enforced-validation option on the command line with or without the ON value. With validation enforcement enabled, certificates are also validated at the time of reloading them through the ALTER INSTANCE RELOAD TLS statement. This system variable cannot be persisted across reboots. For more information, see Configuring Certificate Validation Enforcement.

  • tls_ciphersuites

    命令行格式Command-Line Format --tls-ciphersuites=ciphersuite_list--tls-ciphersuites=ciphersuite_list
    系统变量System Variable tls_ciphersuites
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value NULL

    服务器允许用于使用 TLSv1.3 的加密连接的密码套件。该值是零个或多个以冒号分隔的密码套件名称列表,这些名称可以从此处列出的密码套件中选择:Which ciphersuites the server permits for encrypted connections that use TLSv1.3. The value is a list of zero or more colon-separated ciphersuite names from among those listed here:

    • TLS_AES_128_GCM_SHA256

    • TLS_AES_256_GCM_SHA384

    • TLS_CHACHA20_POLY1305_SHA256

    • TLS_AES_128_CCM_SHA256

    在设置此变量时,如果尝试在密码列表中包含此处未显示的任何值,将引发错误(ER_BLOCKED_CIPHER)。Trying to include any values in the cipher list that are not shown here when setting this variable raises an error (ER_BLOCKED_CIPHER).

    可以为此变量命名的密码套件取决于用于编译 MySQL 的 SSL 库。如果未设置此变量,其默认值为 NULL,这意味着服务器允许默认的密码套件集。如果将该变量设置为空字符串,则不启用任何密码套件,并且无法建立加密连接。有关更多信息,请参见 第 8.3.2 节,“加密连接 TLS 协议和密码套件”。The ciphersuites that can be named for this variable depend on the SSL library used to compile MySQL. If this variable is not set, its default value is NULL, which means that the server permits the default set of ciphersuites. If the variable is set to the empty string, no ciphersuites are enabled and encrypted connections cannot be established. For more information, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.

  • tls_version

    命令行格式Command-Line Format --tls-version=protocol_list--tls-version=protocol_list
    系统变量System Variable tls_version
    范围Scope 全球Global
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String
    默认值Default Value TLSv1.2,TLSv1.3

    服务器允许用于加密连接的协议。该值是一个包含一个或多个逗号分隔协议名称的列表,名称不区分大小写。可以为此变量指定的协议取决于用于编译 MySQL 的 SSL 库。应选择允许的协议,以避免在列表中留下“漏洞”。有关详细信息,请参阅第 8.3.2 节,“加密连接 TLS 协议和密码”.Which protocols the server permits for encrypted connections. The value is a list of one or more comma-separated protocol names, which are not case-sensitive. The protocols that can be named for this variable depend on the SSL library used to compile MySQL. Permitted protocols should be chosen such as not to leave “holes” in the list. For details, see Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.

    此变量可以在运行时修改,以影响服务器用于新连接的 TLS 上下文。请参见 加密连接的服务器端运行时配置和监控。This variable can be modified at runtime to affect the TLS context the server uses for new connections. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.

    Important
    • MySQL 8.4 不支持 TLSv1 和 TLSv1.1 连接协议。有关详细信息,请参阅 删除对 TLSv1 和 TLSv1.1 协议的支持。MySQL 8.4 does not support the TLSv1 and TLSv1.1 connection protocols. See Removal of Support for the TLSv1 and TLSv1.1 Protocols for more information.

    • MySQL 8.4 支持 TLSv1.3 协议,但前提是 MySQL 服务器使用 OpenSSL 1.1.1 或更高版本编译。服务器在启动时检查 OpenSSL 版本,如果低于 1.1.1,则在系统变量的默认值中移除 TLSv1.3。在这种情况下,默认值为 TLSv1.2。Support for the TLSv1.3 protocol is available in MySQL 8.4, provided that MySQL Server was compiled using OpenSSL 1.1.1 or higher. The server checks the version of OpenSSL at startup, and if it is lower than 1.1.1, TLSv1.3 is removed from the default value for the system variable. In that case, the default is TLSv1.2.

    将此变量设置为空字符串将禁用加密连接。Setting this variable to an empty string disables encrypted connections.

  • tmp_table_size

    命令行格式Command-Line Format --tmp-table-size=#
    系统变量System Variable tmp_table_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 整数Integer
    默认值Default Value 16777216
    最小值Minimum Value 1024
    最大值Maximum Value 18446744073709551615
    单位Unit 字节bytes

    定义由 MEMORY 和 TempTable 存储引擎创建的内部内存临时表的最大大小。如果内部内存临时表超过此大小,它将自动转换为磁盘上的内部临时表。Defines the maximum size of internal in-memory temporary tables created by the MEMORY and TempTable storage engines. If an internal in-memory temporary table exceeds this size, it is automatically converted to an on-disk internal temporary table.

    tmp_table_size 变量不适用于用户创建的 MEMORY 表。不支持用户创建的 TempTable 表。The tmp_table_size variable does not apply to user-created MEMORY tables. User-created TempTable tables are not supported.

    当使用 MEMORY 存储引擎来处理内部内存临时表时,实际大小限制为 tmp_table_size 和 max_heap_table_size 中的较小值。max_heap_table_size 设置不适用于 TempTable 表。When using the MEMORY storage engine for internal in-memory temporary tables, the actual size limit is the smaller of tmp_table_size and max_heap_table_size. The max_heap_table_size setting does not apply to TempTable tables.

    如果你执行许多高级的 GROUP BY 查询并且有大量内存,请增加 tmp_table_size 的值(以及在使用 MEMORY 存储引擎处理内部内存临时表时,如有必要,也增加 max_heap_table_size)。Increase the value of tmp_table_size (and max_heap_table_size if necessary when using the MEMORY storage engine for internal in-memory temporary tables) if you do many advanced GROUP BY queries and you have lots of memory.

    您可以通过比较 Created_tmp_disk_tables 和 Created_tmp_tables 的数值,来比较创建的内部磁盘临时表数量与创建的内部临时表总数。You can compare the number of internal on-disk temporary tables created to the total number of internal temporary tables created by comparing Created_tmp_disk_tables and Created_tmp_tables values.

    另请参见 第 10.4.4 节,“MySQL 中的内部临时表使用”。See also Section 10.4.4, “Internal Temporary Table Use in MySQL”.

  • tmpdir

    命令行格式Command-Line Format --tmpdir=dir_name--tmpdir=dir_name
    系统变量System Variable tmpdir
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 目录名称Directory name

    用于创建临时文件的目录路径。如果默认的/tmp目录所在的分区过小而无法容纳临时表,则此设置可能会很有用。此变量可以设置为几个路径的列表,这些路径将以轮换方式使用。在 Unix 系统中,路径应使用冒号字符 (:) 分隔;在 Windows 系统中,应使用分号字符 (;) 分隔。The path of the directory to use for creating temporary files. It might be useful if your default /tmp directory resides on a partition that is too small to hold temporary tables. This variable can be set to a list of several paths that are used in round-robin fashion. Paths should be separated by colon characters (:) on Unix and semicolon characters (;) on Windows.

    tmpdir 可以是一个非永久性的位置,例如基于内存的文件系统上的目录,或者在服务器主机重启时会被清空的目录。如果 MySQL 服务器作为副本运行,并且你为 tmpdir 使用非永久性位置,请考虑使用 replica_load_tmpdir 变量为副本设置一个不同的临时目录。对于副本,用于复制 LOAD DATA 语句的临时文件存储在此目录中,因此使用永久位置它们可以在机器重启后仍然存在,尽管即使临时文件被删除,复制在重启之后仍然可以继续。tmpdir can be a non-permanent location, such as a directory on a memory-based file system or a directory that is cleared when the server host restarts. If the MySQL server is acting as a replica, and you are using a non-permanent location for tmpdir, consider setting a different temporary directory for the replica using the replica_load_tmpdir variable. For a replica, the temporary files used to replicate LOAD DATA statements are stored in this directory, so with a permanent location they can survive machine restarts, although replication can now continue after a restart if the temporary files have been removed.

    有关临时文件存储位置的更多信息,请参见 第 B.3.3.5 节,“MySQL 存储临时文件的位置”。For more information about the storage location of temporary files, see Section B.3.3.5, “Where MySQL Stores Temporary Files”.

  • transaction_alloc_block_size

    命令行格式Command-Line Format --transaction-alloc-block-size=#
    系统变量System Variable transaction_alloc_block_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 8192
    最小值Minimum Value 1024
    最大值Maximum Value 131072
    单位Unit 字节bytes
    块大小Block Size 1024

    每次事务内存池在需要内存时增加的字节数。请参阅transaction_prealloc_size的描述。The amount in bytes by which to increase a per-transaction memory pool which needs memory. See the description of transaction_prealloc_size.

  • transaction_isolation

    命令行格式Command-Line Format --transaction-isolation=name
    系统变量System Variable transaction_isolation
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 枚举Enumeration
    默认值Default Value REPEATABLE-READREPEATABLE-READ
    有效值Valid Values

    READ-UNCOMMITTEDREAD-UNCOMMITTED

    READ-COMMITTEDREAD-COMMITTED

    REPEATABLE-READREPEATABLE-READ

    SERIALIZABLESERIALIZABLE

    事务隔离级别。默认值是 REPEATABLE-READ。The transaction isolation level. The default is REPEATABLE-READ.

    事务隔离级别有三个范围:全局、会话和下一次事务。这种三范围实现导致了一些非标准的隔离级别分配语义,如后文所述。The transaction isolation level has three scopes: global, session, and next transaction. This three-scope implementation leads to some nonstandard isolation-level assignment semantics, as described later.

    要在启动时设置全局事务隔离级别,请使用 --transaction-isolation 服务器选项。To set the global transaction isolation level at startup, use the --transaction-isolation server option.

    在运行时,可以直接使用 SET 语句为 transaction_isolation 系统变量分配值,或者间接使用 SET TRANSACTION 语句。如果你直接将 transaction_isolation 设置为包含空格的隔离级别名称,则名称应使用引号括起来,并将空格替换为连字符。例如,使用以下 SET 语句来设置全局值:At runtime, the isolation level can be set directly using the SET statement to assign a value to the transaction_isolation system variable, or indirectly using the SET TRANSACTION statement. If you set transaction_isolation directly to an isolation level name that contains a space, the name should be enclosed within quotation marks, with the space replaced by a dash. For example, use this SET statement to set the global value:

    SET GLOBAL transaction_isolation = 'READ-COMMITTED';
    

    设置全局 transaction_isolation 值会为所有后续会话设置隔离级别。现有会话不受影响。Setting the global transaction_isolation value sets the isolation level for all subsequent sessions. Existing sessions are unaffected.

    要设置会话或下一级 transaction_isolation 值,请使用 SET 语句。对于大多数会话系统变量,这些语句是设置值的等效方式:To set the session or next-level transaction_isolation value, use the SET statement. For most session system variables, these statements are equivalent ways to set the value:

    SET @@SESSION.var_name = value;
    SET SESSION var_name = value;
    SET var_name = value;
    SET @@var_name = value;
    

    如前所述,事务隔离级别除了全局和会话范围之外,还有下一个事务范围。为了启用可以设置下一个事务范围,为会话系统变量赋值的 SET 语法对 transaction_isolation 有非标准语义:As mentioned previously, the transaction isolation level has a next-transaction scope, in addition to the global and session scopes. To enable the next-transaction scope to be set, SET syntax for assigning session system variable values has nonstandard semantics for transaction_isolation:

    • 要设置会话隔离级别,可以使用以下任意语法:To set the session isolation level, use any of these syntaxes:

      SET @@SESSION.transaction_isolation = value;
      SET SESSION transaction_isolation = value;
      SET transaction_isolation = value;
      

      对于每种语法,适用以下语义:For each of those syntaxes, these semantics apply:

      • 为会话中随后执行的所有事务设置隔离级别。Sets the isolation level for all subsequent transactions performed within the session.

      • 允许在事务中使用,但不会影响当前正在进行的事务。Permitted within transactions, but does not affect the current ongoing transaction.

      • 如果在事务之间执行,则会覆盖任何之前设置下一事务隔离级别的语句。If executed between transactions, overrides any preceding statement that sets the next-transaction isolation level.

      • 对应于 SET SESSION TRANSACTION ISOLATION LEVEL(带有 SESSION 关键字)。Corresponds to SET SESSION TRANSACTION ISOLATION LEVEL (with the SESSION keyword).

    • 要设置下一事务的隔离级别,请使用以下语法:To set the next-transaction isolation level, use this syntax:

      SET @@transaction_isolation = value;
      

      对于该语法,适用以下语义:For that syntax, these semantics apply:

      • 仅为会话中执行的下一单个事务设置隔离级别。Sets the isolation level only for the next single transaction performed within the session.

      • 后续事务将恢复为会话隔离级别。Subsequent transactions revert to the session isolation level.

      • 不允许在事务中使用。Not permitted within transactions.

      • 对应于 SET TRANSACTION ISOLATION LEVEL(不带 SESSION 关键字)。Corresponds to SET TRANSACTION ISOLATION LEVEL (without the SESSION keyword).

    有关 SET TRANSACTION 及其与 transaction_isolation 系统变量的关系的更多信息,请参见 第 15.3.7 节,“SET TRANSACTION 语句”。For more information about SET TRANSACTION and its relationship to the transaction_isolation system variable, see Section 15.3.7, “SET TRANSACTION Statement”.

  • transaction_prealloc_size

    命令行格式Command-Line Format --transaction-prealloc-size=#
    已弃用Deprecated 是Yes
    系统变量System Variable transaction_prealloc_size
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 4096
    最小值Minimum Value 1024
    最大值Maximum Value 131072
    单位Unit 字节bytes
    块大小Block Size 1024

    每个事务都有一个事务内存池,各种与事务相关的分配都会从该内存池获取内存。内存池的初始大小(以字节为单位)为 transaction_prealloc_size。对于那些由于内存池可用内存不足而无法满足的分配,内存池会增加 transaction_alloc_block_size 字节。当事务结束时,内存池会被截断为 transaction_prealloc_size 字节。通过将 transaction_prealloc_size 设置得足够大以容纳单个事务中的所有语句,可以避免许多 malloc() 调用。There is a per-transaction memory pool from which various transaction-related allocations take memory. The initial size of the pool in bytes is transaction_prealloc_size. For every allocation that cannot be satisfied from the pool because it has insufficient memory available, the pool is increased by transaction_alloc_block_size bytes. When the transaction ends, the pool is truncated to transaction_prealloc_size bytes. By making transaction_prealloc_size sufficiently large to contain all statements within a single transaction, you can avoid many malloc() calls.

    transaction_prealloc_size 已被弃用,设置此变量不再有效。预计 transaction_prealloc_size 将在 MySQL 的未来版本中移除。transaction_prealloc_size is deprecated, and setting this variable no longer has any effect. Expect transaction_prealloc_size to be removed in a future release of MySQL.

  • transaction_read_only

    命令行格式Command-Line Format --transaction-read-only[={OFF|ON}]
    系统变量System Variable transaction_read_only
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value OFFOFF

    事务访问模式。其值可以是 OFF(读/写;默认)或 ON(只读)。The transaction access mode. The value can be OFF (read/write; the default) or ON (read only).

    事务访问模式具有三个范围:全局、会话和下一事务。这种三范围的实现方式导致一些非标准的访问模式分配语义,如后文所述。The transaction access mode has three scopes: global, session, and next transaction. This three-scope implementation leads to some nonstandard access-mode assignment semantics, as described later.

    要在启动时设置全局事务访问模式,请使用 --transaction-read-only 服务器选项。To set the global transaction access mode at startup, use the --transaction-read-only server option.

    在运行时,可以直接使用 SET 语句为 transaction_read_only 系统变量赋值,或者间接使用 SET TRANSACTION 语句。例如,使用此 SET 语句设置全局值:At runtime, the access mode can be set directly using the SET statement to assign a value to the transaction_read_only system variable, or indirectly using the SET TRANSACTION statement. For example, use this SET statement to set the global value:

    SET GLOBAL transaction_read_only = ON;
    

    设置全局 transaction_read_only 值会为所有后续会话设置访问模式。现有会话不受影响。Setting the global transaction_read_only value sets the access mode for all subsequent sessions. Existing sessions are unaffected.

    要设置会话或下一级的 transaction_read_only 值,请使用 SET 语句。对于大多数会话系统变量,这些语句是设置值的等效方式:To set the session or next-level transaction_read_only value, use the SET statement. For most session system variables, these statements are equivalent ways to set the value:

    SET @@SESSION.var_name = value;
    SET SESSION var_name = value;
    SET var_name = value;
    SET @@var_name = value;
    

    如前所述,事务访问模式除了全局和会话作用域外,还有一个下一个事务作用域。为了启用下一个事务作用域的设置,SET 用于分配会话系统变量值的语法,对于 transaction_read_only 具有非标准语义,As mentioned previously, the transaction access mode has a next-transaction scope, in addition to the global and session scopes. To enable the next-transaction scope to be set, SET syntax for assigning session system variable values has nonstandard semantics for transaction_read_only,

    • 要设置会话访问模式,请使用以下任意语法:To set the session access mode, use any of these syntaxes:

      SET @@SESSION.transaction_read_only = value;
      SET SESSION transaction_read_only = value;
      SET transaction_read_only = value;
      

      对于每种语法,适用以下语义:For each of those syntaxes, these semantics apply:

      • 设置会话中执行的所有后续事务的访问模式。Sets the access mode for all subsequent transactions performed within the session.

      • 允许在事务中使用,但不会影响当前正在进行的事务。Permitted within transactions, but does not affect the current ongoing transaction.

      • 如果在事务之间执行,将覆盖任何先前设置下一个事务访问模式的语句。If executed between transactions, overrides any preceding statement that sets the next-transaction access mode.

      • 对应 SET SESSION TRANSACTION {READ WRITE | READ ONLY}(带 SESSION 关键字)。Corresponds to SET SESSION TRANSACTION {READ WRITE | READ ONLY} (with the SESSION keyword).

    • 要设置下一个事务的访问模式,请使用此语法:To set the next-transaction access mode, use this syntax:

      SET @@transaction_read_only = value;
      

      对于该语法,适用以下语义:For that syntax, these semantics apply:

      • 仅为会话中执行的下一个单独事务设置访问模式。Sets the access mode only for the next single transaction performed within the session.

      • 后续事务将恢复为会话访问模式。Subsequent transactions revert to the session access mode.

      • 不允许在事务中使用。Not permitted within transactions.

      • 对应 SET TRANSACTION {READ WRITE | READ ONLY}(不带 SESSION 关键字)。Corresponds to SET TRANSACTION {READ WRITE | READ ONLY} (without the SESSION keyword).

    有关 SET TRANSACTION 及其与 transaction_read_only 系统变量的关系的更多信息,请参阅 第 15.3.7 节,“SET TRANSACTION 语句”。For more information about SET TRANSACTION and its relationship to the transaction_read_only system variable, see Section 15.3.7, “SET TRANSACTION Statement”.

  • unique_checks

    系统变量System Variable unique_checks
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value ONON

    如果设置为 1(默认值),则会对 InnoDB 表中的二级索引执行唯一性检查。如果设置为 0,则允许存储引擎假定输入数据中不存在重复键。如果你确定你的数据不包含唯一性冲突,可以将其设置为 0,以加快大表导入 InnoDB 的速度。If set to 1 (the default), uniqueness checks for secondary indexes in InnoDB tables are performed. If set to 0, storage engines are permitted to assume that duplicate keys are not present in input data. If you know for certain that your data does not contain uniqueness violations, you can set this to 0 to speed up large table imports to InnoDB.

    将此变量设置为 0 并不 要求存储引擎忽略重复键。引擎仍然可以检查它们,并在发现重复键时发出重复键错误。Setting this variable to 0 does not require storage engines to ignore duplicate keys. An engine is still permitted to check for them and issue duplicate-key errors if it detects them.

  • updatable_views_with_limit

    命令行格式Command-Line Format --updatable-views-with-limit[={OFF|ON}]
    系统变量System Variable updatable_views_with_limit
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value 1

    此变量控制在视图未包含底层表中定义的主键的所有列时,是否可以对视图进行更新,如果更新语句包含LIMIT子句。(此类更新通常由 GUI 工具生成。)更新指的是UPDATE或DELETE语句。这里的主键指的是PRIMARY KEY,或其中没有列可以包含NULL的UNIQUE索引。This variable controls whether updates to a view can be made when the view does not contain all columns of the primary key defined in the underlying table, if the update statement contains a LIMIT clause. (Such updates often are generated by GUI tools.) An update is an UPDATE or DELETE statement. Primary key here means a PRIMARY KEY, or a UNIQUE index in which no column can contain NULL.

    该变量可以有两个值:The variable can have two values:

    • 1 或 YES:仅发出警告(不是错误信息)。这是默认值。1 or YES: Issue a warning only (not an error message). This is the default value.

    • 0 或 NO:禁止更新。0 or NO: Prohibit the update.

  • use_secondary_engine

    仅用于 MySQL HeatWave。有关更多信息,请参阅 系统变量。For use with MySQL HeatWave only. See System Variables, for more information.

  • validate_password.xxx

    validate_password 组件实现了一组系统变量,这些变量的名称形式为 validate_password.xxx。这些变量会影响该组件的密码测试;参见 第 8.4.3.2 节,“密码验证选项和变量”。The validate_password component implements a set of system variables having names of the form validate_password.xxx. These variables affect password testing by that component; see Section 8.4.3.2, “Password Validation Options and Variables”.

  • version

    服务器的版本号。该值还可能包含表示服务器构建或配置信息的后缀。-debug 表示服务器是在启用调试支持的情况下构建的。The version number for the server. The value might also include a suffix indicating server build or configuration information. -debug indicates that the server was built with debugging support enabled.

  • version_comment

    系统变量System Variable version_comment
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    CMake 配置程序有一个 COMPILATION_COMMENT_SERVER 选项,允许在构建 MySQL 时指定注释。该变量包含该注释的值。The CMake configuration program has a COMPILATION_COMMENT_SERVER option that permits a comment to be specified when building MySQL. This variable contains the value of that comment.

  • version_compile_machine

    系统变量System Variable version_compile_machine
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    服务器二进制文件的类型。The type of the server binary.

  • version_compile_os

    系统变量System Variable version_compile_os
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    MySQL 构建时使用的操作系统类型。The type of operating system on which MySQL was built.

  • version_compile_zlib

    系统变量System Variable version_compile_zlib
    范围Scope 全球Global
    动态Dynamic 否No
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 字符串String

    编译内置的 zlib 库的版本。The version of the compiled-in zlib library.

  • wait_timeout

    命令行格式Command-Line Format --wait-timeout=#
    系统变量System Variable wait_timeout
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 整数Integer
    默认值Default Value 28800
    最小值Minimum Value 1
    最大值(Windows)Maximum Value (Windows) 2147483
    最大值(其他)Maximum Value (Other) 31536000
    单位Unit 秒seconds

    服务器在关闭非交互连接之前等待活动的秒数。The number of seconds the server waits for activity on a noninteractive connection before closing it.

    在线程启动时,会话 wait_timeout 值会根据客户端类型(由 mysql_real_connect() 的 CLIENT_INTERACTIVE 连接选项定义)从全局 wait_timeout 值或全局 interactive_timeout 值初始化。另请参见 interactive_timeout。On thread startup, the session wait_timeout value is initialized from the global wait_timeout value or from the global interactive_timeout value, depending on the type of client (as defined by the CLIENT_INTERACTIVE connect option to mysql_real_connect()). See also interactive_timeout.

  • warning_count

    从最后生成消息的语句产生的错误、警告和注意事项的数量。此变量为只读。参见 第 15.7.7.42 节,“SHOW WARNINGS 语句”。The number of errors, warnings, and notes that resulted from the last statement that generated messages. This variable is read only. See Section 15.7.7.42, “SHOW WARNINGS Statement”.

  • windowing_use_high_precision

    命令行格式Command-Line Format --windowing-use-high-precision[={OFF|ON}]
    系统变量System Variable windowing_use_high_precision
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 是Yes
    类型Type 布尔Boolean
    默认值Default Value ONON

    是否在计算窗口操作时保持精度。请参见第 10.2.1.21 节,“窗口函数优化”。Whether to compute window operations without loss of precision. See Section 10.2.1.21, “Window Function Optimization”.

  • xa_detach_on_prepare

    命令行格式Command-Line Format --xa-detach-on-prepare[={OFF|ON}]
    系统变量System Variable xa_detach_on_prepare
    范围Scope 全局,会话Global, Session
    动态Dynamic 是Yes
    SET_VAR 提示适用SET_VAR Hint Applies 否No
    类型Type 布尔Boolean
    默认值Default Value ONON

    当设置为ON(启用)时,所有 XA 事务都会在XA PREPARE的一部分中从连接(会话)中分离(断开)。这意味着,即使原始连接尚未终止,XA 事务也可以由另一个连接提交或回滚,而且该连接可以启动新的事务。When set to ON (enabled), all XA transactions are detached (disconnected) from the connection (session) as part of XA PREPARE. This means that the XA transaction can be committed or rolled back by another connection, even if the originating connection has not terminated, and this connection can start new transactions.

    临时表不能在分离的 XA 事务中使用。Temporary tables cannot be used inside detached XA transactions.

    当设置为OFF(禁用)时,XA 事务严格与同一连接关联,直到会话断开。建议允许启用此功能(默认行为)以进行复制。When this is OFF (disabled), an XA transaction is strictly associated with the same connection until the session disconnects. It is recommended that you allow it to be enabled (the default behavior) for replication.

    有关更多信息,请参见 第 15.3.8.2 节,“XA 事务状态”。For more information, see Section 15.3.8.2, “XA Transaction States”.