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 theSHOW VARIABLESstatement 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:
第 7.1.9 节,“使用系统变量”,讨论了设置和显示系统变量值的语法。Section 7.1.9, “Using System Variables”, discusses the syntax for setting and displaying system variable values.
第 7.1.9.2 节,“动态系统变量”,列出了可以在运行时设置的变量。Section 7.1.9.2, “Dynamic System Variables”, lists the variables that can be set at runtime.
有关调整系统变量的信息,请参阅 第 7.1.1 节,“配置服务器”。Information on tuning system variables can be found in Section 7.1.1, “Configuring the Server”.
第 17.14 节,“InnoDB 启动选项和系统变量”,列出了
InnoDB系统变量。Section 17.14, “InnoDB Startup Options and System Variables”, listsInnoDBsystem variables.第 25.4.3.9.2 节,“NDB Cluster 系统变量”,列出了特定于 NDB Cluster 的系统变量。Section 25.4.3.9.2, “NDB Cluster System Variables”, lists system variables which are specific to NDB Cluster.
有关特定于复制的服务器系统变量的信息,请参阅 第 19.1.6 节,“复制和二进制日志选项及变量”。For information on server system variables specific to replication, see Section 19.1.6, “Replication and Binary Logging Options and Variables”.
以下一些变量描述涉及 “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.
某些系统变量的描述包括块大小,在这种情况下,如果值不是所述块大小的整数倍,则在服务器存储之前会向下舍入到块大小的下一个较低倍数,即FLOOR( value)* 。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
block_sizeFLOOR(
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.
命令行格式Command-Line Format --activate-all-roles-on-login[={OFF|ON}]系统变量System Variable activate_all_roles_on_login范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF是否在用户登录服务器时启用所有授予角色的自动激活:Whether to enable automatic activation of all granted roles when users log in to the server:
如果启用了
activate_all_roles_on_login,服务器将在登录时激活授予每个账户的所有角色。这优先于使用SET DEFAULT ROLE指定的默认角色。Ifactivate_all_roles_on_loginis enabled, the server activates all roles granted to each account at login time. This takes precedence over default roles specified withSET DEFAULT ROLE.如果禁用了
activate_all_roles_on_login,服务器将在登录时激活使用SET DEFAULT ROLE指定的默认角色(如果有)。Ifactivate_all_roles_on_loginis disabled, the server activates the default roles specified withSET DEFAULT ROLE, if any, at login time.
授予的角色包括显式授予用户的角色以及在
mandatory_roles系统变量值中列出的角色。Granted roles include those granted explicitly to the user and those named in themandatory_rolessystem variable value.activate_all_roles_on_login仅在登录时以及在以定义者上下文执行的存储程序和视图开始执行时生效。要在会话中更改活动角色,请使用SET ROLE。要更改存储程序的活动角色,程序主体应执行SET ROLE。activate_all_roles_on_loginapplies 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, useSET ROLE. To change the active roles for a stored program, the program body should executeSET ROLE.命令行格式Command-Line Format --admin-address=addr--admin-address=addr系统变量System Variable admin_address范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 defaultadmin_addressvalue. If this variable is not specified at startup, the server maintains no administrative interface. The server also has abind_addresssystem variable for configuring regular (nonadministrative) client TCP/IP connections. See Section 7.1.12.1, “Connection Interfaces”.如果指定了
admin_address,其值必须满足以下要求:Ifadmin_addressis 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.1or--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 as127.0.0.1or::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.
对于给定的地址,网络命名空间是可选的。如果提供,必须作为紧跟地址的一个
/后缀来指定。For a given address, the network namespace is optional. If given, it must be specified as ans/suffix immediately following the address.ns没有
/后缀的地址使用主机系统的全局命名空间。因此,全局命名空间是默认值。An address with nons/suffix uses the host system global namespace. The global namespace is therefore the default.ns带有
/后缀的地址使用名为nsns的命名空间。An address with a/suffix uses the namespace namednsns.主机系统必须支持网络命名空间,并且每个命名的命名空间必须事先设置好。命名不存在的命名空间会产生错误。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系统变量,它将服务器绑定到用于普通客户端连接的地址,但有以下区别:Theadmin_addresssystem variable is similar to thebind_addresssystem variable that binds the server to an address for ordinary client connections, but with these differences:bind_address允许多个地址。admin_address只允许单个地址。bind_addresspermits multiple addresses.admin_addresspermits a single address.bind_address允许通配符地址。admin_address不允许。bind_addresspermits wildcard addresses.admin_addressdoes not.
命令行格式Command-Line Format --admin-port=port_num--admin-port=port_num系统变量System Variable admin_port范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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无效,因为在这种情况下,服务器不会维护任何管理网络接口。Settingadmin_porthas no effect ifadmin_addressis not specified because in that case the server maintains no administrative network interface.命令行格式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_VARHint Applies否No 类型Type 文件名File name 默认值Default Value NULLadmin_ssl_ca系统变量类似于ssl_ca,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参阅 管理接口加密连接支持。Theadmin_ssl_casystem variable is likessl_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.命令行格式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_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value NULLadmin_ssl_capath系统变量类似于ssl_capath,只是它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参阅 管理接口加密连接支持。Theadmin_ssl_capathsystem variable is likessl_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.命令行格式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_VARHint Applies否No 类型Type 文件名File name 默认值Default Value NULLadmin_ssl_cert系统变量类似于ssl_cert,区别在于它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参阅 管理接口加密连接支持。Theadmin_ssl_certsystem variable is likessl_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.命令行格式Command-Line Format --admin-ssl-cipher=name系统变量System Variable admin_ssl_cipher范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value NULLadmin_ssl_cipher系统变量类似于ssl_cipher,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参阅 管理接口加密连接支持。Theadmin_ssl_ciphersystem variable is likessl_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-SHA256ECDHE-ECDSA-AES256-GCM-SHA384ECDHE-RSA-AES128-GCM-SHA256ECDHE-RSA-AES256-GCM-SHA384ECDHE-ECDSA-CHACHA20-POLY1305ECDHE-RSA-CHACHA20-POLY1305ECDHE-ECDSA-AES256-CCMECDHE-ECDSA-AES128-CCMDHE-RSA-AES128-GCM-SHA256DHE-RSA-AES256-GCM-SHA384DHE-RSA-AES256-CCMDHE-RSA-AES128-CCMDHE-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).命令行格式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_VARHint Applies否No 类型Type 文件名File name 默认值Default Value NULLadmin_ssl_crl系统变量类似于ssl_crl,只是它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参见 管理接口加密连接支持。Theadmin_ssl_crlsystem variable is likessl_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.命令行格式Command-Line Format --admin-ssl-crlpath=dir_name系统变量System Variable admin_ssl_crlpath范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value NULLadmin_ssl_crlpath系统变量类似于ssl_crlpath,只是它适用于管理连接接口,而不是主连接接口。有关为管理接口配置加密支持的信息,请参阅 行政接口对加密连接的支持。Theadmin_ssl_crlpathsystem variable is likessl_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.命令行格式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_VARHint Applies否No 类型Type 文件名File name 默认值Default Value NULLadmin_ssl_key系统变量类似于ssl_key,不同之处在于它适用于管理连接接口而非主连接接口。有关配置管理接口加密支持的信息,请参见 管理接口加密连接支持。Theadmin_ssl_keysystem variable is likessl_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.命令行格式Command-Line Format --admin-tls-ciphersuites=ciphersuite_list系统变量System Variable admin_tls_ciphersuites范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value NULLadmin_tls_ciphersuites系统变量类似于tls_ciphersuites,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参阅 管理接口加密连接支持。Theadmin_tls_ciphersuitessystem variable is liketls_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_SHA256TLS_AES_256_GCM_SHA384TLS_CHACHA20_POLY1305_SHA256TLS_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).命令行格式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_VARHint Applies否No 类型Type 字符串String 默认值Default Value TLSv1.2,TLSv1.3admin_tls_version系统变量类似于tls_version,只是它适用于管理连接接口,而不是主连接接口。有关配置管理接口加密支持的信息,请参见 管理接口加密连接支持。Theadmin_tls_versionsystem variable is liketls_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.ImportantMySQL 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 isTLSv1.2.
命令行格式Command-Line Format --authentication-policy=value系统变量System Variable authentication_policy范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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. ForCREATE USERandALTER USERstatements 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_policydetermines 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仅在创建或修改账户时适用,所以其值的更改不会影响现有用户账户。Becauseauthentication_policyapplies 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 theauthentication_policysystem variable places certain constraints on the authentication-related clauses ofCREATE USERandALTER USERstatements, a user who has theAUTHENTICATION_POLICY_ADMINprivilege 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 ofauthentication_policyis 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 beplugin_name.*:plugin_name需要身份验证因素;
plugin_name是默认值,但也可以使用其他身份验证插件。The authentication factor is required;plugin_nameis 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_policymust 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 ofauthentication_policyis'*,,'. This means that factor 1 is required in account definitions and can use any authentication plugin (withcaching_sha2_passwordbeing the default), and that factors 2 and 3 are optional and each can use any authentication plugin.如果
authentication_policy没有为第一因素指定默认插件,则该因素的默认插件是caching_sha2_password,虽然也可以使用其他插件。Ifauthentication_policydoes not specify a default plugin for the first factor, the default plugin for this factor iscaching_sha2_password, although another plugin may be used.下表显示了一些
authentication_policy的可能值以及每个值在创建或更改账户时所建立的策略。The following table shows some possible values forauthentication_policyand 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 usescaching_sha2_password, although another plugin may be used.'*,*'仅两个因素;第一个因素默认使用 caching_sha2_password,尽管可以使用其他插件;第二个因素可以使用任何插件。Two factors only; the first factor usescaching_sha2_passwordby default, although another plugin may be used; the second may use any plugin.'*,*,*'仅三个因素,其中第一个因素默认使用 caching_sha2_password,尽管可以使用其他插件;第二和第三个因素可以使用任何插件。Three factors only, where the first factor usescaching_sha2_passwordby 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 usescaching_sha2_passwordby 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 usescaching_sha2_passwordby 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 usescaching_sha2_passwordby 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 usescaching_sha2_passwordby 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 usescaching_sha2_passwordby 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_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2最小值Minimum Value 0最大值Maximum Value 4仅当启用了
authentication_windowsWindows 身份验证插件并启用了调试代码时,此变量才可用。请参阅 第 8.4.1.6 节,“Windows 可插拔身份验证”。This variable is available only if theauthentication_windowsWindows 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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON该变量仅在启用
authentication_windowsWindows 身份验证插件时可用。参见 第 8.4.1.6 节,“Windows 插件式身份验证”。This variable is available only if theauthentication_windowsWindows authentication plugin is enabled. See Section 8.4.1.6, “Windows Pluggable Authentication”.使用
InitSecurityContext()函数进行身份验证的客户端应提供一个标识其连接的服务的字符串 (targetName)。MySQL 使用服务器运行帐户的主体名称 (UPN)。UPN 的形式为,无需在任何地方注册即可使用。该 UPN 会在身份验证握手开始时由服务器发送。A client that authenticates using theuser_id@computer_nameInitSecurityContext()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 formand need not be registered anywhere to be used. This UPN is sent by the server at the beginning of authentication handshake.user_id@computer_name此变量用于控制服务器是否在初始挑战中发送 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 a0x00byte in the first challenge, the client does not specifytargetName, 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.
命令行格式Command-Line Format --autocommit[={OFF|ON}]--autocommit[={OFF|ON}]系统变量System Variable autocommitautocommit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 useCOMMITto accept a transaction orROLLBACKto cancel it. Ifautocommitis 0 and you change it to 1, MySQL performs an automaticCOMMITof any open transaction. Another way to begin a transaction is to use aSTART TRANSACTIONorBEGINstatement. See Section 15.3.1, “START TRANSACTION, COMMIT, and ROLLBACK Statements”.默认情况下,客户端连接的
autocommit设置为 1。若要使客户端以默认 0 开始,请通过使用--autocommit=0选项启动服务器来设置全局autocommit值。要使用选项文件设置该变量,请包含以下行:By default, client connections begin withautocommitset to 1. To cause clients to begin with a default of 0, set the globalautocommitvalue by starting the server with the--autocommit=0option. To set the variable using an option file, include these lines:[mysqld] autocommit=0
命令行格式Command-Line Format --automatic-sp-privileges[={OFF|ON}]系统变量System Variable automatic_sp_privileges范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theEXECUTEandALTER ROUTINEprivileges to the creator of a stored routine, if the user cannot already execute and alter or drop the routine. (TheALTER ROUTINEprivilege is required to drop the routine.) The server also automatically drops those privileges from the creator when the routine is dropped. Ifautomatic_sp_privilegesis 0, the server does not automatically add or drop these privileges.例程的创建者是用于执行
CREATE语句的账户。这可能与例程定义中作为DEFINER指定的账户不同。The creator of a routine is the account used to execute theCREATEstatement for it. This might not be the same as the account named as theDEFINERin the routine definition.如果你用 mysqld 并加上
--skip-new启动,automatic_sp_privileges将被设置为OFF。If you start mysqld with--skip-new,automatic_sp_privilegesis set toOFF.另请参见 第 27.2.2 节,“存储例程与 MySQL 权限”。See also Section 27.2.2, “Stored Routines and MySQL Privileges”.
命令行格式Command-Line Format --auto-generate-certs[={OFF|ON}]系统变量System Variable auto_generate_certs范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 theauto_generate_certssystem 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 密钥对文件的自动生成。Thesha256_password_auto_generate_rsa_keysandcaching_sha2_password_auto_generate_rsa_keyssystem variables are related but control autogeneration of RSA key-pair files needed for secure password exchange using RSA over unencrypted connections.命令行格式Command-Line Format --back-log=#系统变量System Variable back_log范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1(signifies autosizing; do not assign this literal value)最小值Minimum Value 1最大值Maximum Value 65535MySQL 可以处理的未完成连接请求的数量。当主 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. Theback_logvalue 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 Unixlisten()system call should have more details. Check your OS documentation for the maximum value for this variable.back_logcannot be set higher than your operating system limit.默认值是
max_connections的值,这允许允许的队列根据允许的最大连接数自动调整。The default value is the value ofmax_connections, which enables the permitted backlog to adjust to the maximum permitted number of connections.命令行格式Command-Line Format --basedir=dir_name--basedir=dir_name系统变量System Variable basedir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 目录名称Directory name 默认值Default Value parent of mysqld installation directoryparent of mysqld installation directoryMySQL 安装基础目录的路径。The path to the MySQL installation base directory.
命令行格式Command-Line Format --big-tables[={OFF|ON}]系统变量System Variable big_tables范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 mostThe tableerrors fortbl_nameis fullSELECToperations 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 isOFF(use in-memory temporary tables). Normally, it should never be necessary to enable this variable. When in-memory internal temporary tables are managed by theTempTablestorage engine (the default), and the maximum amount of memory that can be occupied by theTempTablestorage engine is exceeded, theTempTablestorage engine starts storing data to temporary files on disk. When in-memory temporary tables are managed by theMEMORYstorage 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”.命令行格式Command-Line Format --bind-address=addr--bind-address=addr系统变量System Variable bind_addressbind_address范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 thebind_addresssystem variable at server startup. The server also has anadmin_addresssystem 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或::)。Ifbind_addressis 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 is0.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.1or--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 as127.0.0.1or::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.
对于给定的地址,网络命名空间是可选的。如果提供,必须作为紧跟地址的一个
/后缀来指定。For a given address, the network namespace is optional. If given, it must be specified as ans/suffix immediately following the address.ns没有
/后缀的地址使用主机系统的全局命名空间。因此,全局命名空间是默认值。An address with nons/suffix uses the host system global namespace. The global namespace is therefore the default.ns带有
/后缀的地址使用名为nsns的命名空间。An address with a/suffix uses the namespace namednsns.主机系统必须支持网络命名空间,并且每个命名的命名空间必须事先设置好。命名不存在的命名空间会产生错误。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.20IPv4 地址。The server listens only on the198.51.100.20IPv4 address.bind_address=198.51.100.20,2001:db8:0:f101::1服务器监听
198.51.100.20IPv4 地址和2001:db8:0:f101::1IPv6 地址。The server listens on the198.51.100.20IPv4 address and the2001:db8:0:f101::1IPv6 address.bind_address=198.51.100.20,*命名多个值的列表时不允许使用通配符地址。
bind_address如果你以This produces an error because wildcard addresses are not permitted whenbind_addressnames 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.20IPv4 地址,在blue命名空间中监听2001:db8:0:f101::1IPv6 地址,在全局命名空间中监听192.0.2.50IPv4 地址。The server listens on the198.51.100.20IPv4 address in therednamespace, the2001:db8:0:f101::1IPv6 address in thebluenamespace, and the192.0.2.50IPv4 address in the global namespace.
当
bind_address指定单个值(通配符或非通配符)时,服务器在单个套接字上监听,对于通配符地址,该套接字可能绑定到多个网络接口。当bind_address指定多个值的列表时,服务器为每个值监听一个套接字,每个套接字绑定到单个网络接口。套接字数量与指定值的数量成线性关系。根据操作系统接受连接的效率,较长的值列表可能会对接受 TCP/IP 连接的性能产生影响。Whenbind_addressnames 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. Whenbind_addressnames 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 theopen_files_limitsystem variable.如果您打算将服务器绑定到特定地址,请确保
mysql.user系统表中包含一个具有管理权限的账户,以便您可以使用该账户连接到该地址。否则,您将无法关闭服务器。例如,如果您将服务器绑定到*,您可以使用所有现有账户进行连接。但如果您将服务器绑定到::1,它只接受该地址的连接。在这种情况下,首先确保'root'@'::1'账户存在于mysql.user表中,以便您仍然可以连接到服务器并关闭它。If you intend to bind the server to a specific address, be sure that themysql.usersystem 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 themysql.usertable so you can still connect to the server to shut it down.命令行格式Command-Line Format --block-encryption-mode=#系统变量System Variable block_encryption_mode范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 forAES_ENCRYPT()andAES_DECRYPT().block_encryption_mode的值采用aes-格式,其中keylen-modekeylen是密钥长度(以位为单位),mode是加密模式。该值不区分大小写。允许的keylen值为 128、192 和 256。允许的mode值为ECB、CBC、CFB1、CFB8、CFB128和OFB。block_encryption_modetakes a value inaes-format, wherekeylen-modekeylenis the key length in bits andmodeis the encryption mode. The value is not case-sensitive. Permittedkeylenvalues are 128, 192, and 256. Permittedmodevalues areECB,CBC,CFB1,CFB8,CFB128, andOFB.例如,这条语句使 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 setblock_encryption_modeto a value containing an unsupported key length or a mode that the SSL library does not support.系统变量System Variable build_id范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 特定平台Platform Specific Linux 这是一个 160 位的
SHA1签名,由链接器在 Linux 系统上使用-DWITH_BUILD_ID=ON(默认启用)编译服务器时生成,并转换为十六进制字符串。这个只读值作为唯一的构建 ID,并在启动时写入服务器日志。This is a 160-bitSHA1signature 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_idis not supported on platforms other than Linux.bulk_insert_buffer_sizebulk_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_VARHint 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。MyISAMuses a special tree-like cache to make bulk inserts faster forINSERT ... SELECT,INSERT ... VALUES (...), (...), ..., andLOAD DATAwhen 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_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 5000最小值Minimum Value 5000最大值Maximum Value 4095000caching_sha2_password认证插件用于密码存储的哈希轮数。The number of hash rounds used by thecaching_sha2_passwordauthentication 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 thecaching_sha2_passwordplugin 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_VARHint 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: Thesha256_password_auto_generate_rsa_keysorcaching_sha2_password_auto_generate_rsa_keyssystem 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 thesha256_password(deprecated) orcaching_sha2_passwordplugin; 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 证书和密钥文件的自动生成。Theauto_generate_certssystem 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_VARHint 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 thecaching_sha2_passwordauthentication 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 aboutcaching_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_VARHint 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 thecaching_sha2_passwordauthentication 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 aboutcaching_sha2_password, including information about how clients request the RSA public key, see Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”.系统变量System Variable character_set_client范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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-setoption 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 requestssjiswhen connecting to a server not configured withsjissupport.某些字符集不能用作客户端字符集。尝试将它们用作
character_set_client值会产生错误。请参阅 不允许的客户端字符集。Some character sets cannot be used as the client character set. Attempting to use them as thecharacter_set_clientvalue produces an error. See Impermissible Client Character Sets.系统变量System Variable character_set_connection范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
系统变量System Variable character_set_database范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ascharacter_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 globalcharacter_set_databaseandcollation_databasesystem 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 sessioncharacter_set_databaseandcollation_databasesystem 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.命令行格式Command-Line Format --character-set-filesystem=name系统变量System Variable character_set_filesystem范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theLOAD DATAandSELECT ... INTO OUTFILEstatements and theLOAD_FILE()function. Such file names are converted fromcharacter_set_clienttocharacter_set_filesystembefore the file opening attempt occurs. The default value isbinary, 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, setcharacter_set_filesystemto'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”.
系统变量System Variable character_set_results范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --character-set-server=name系统变量System Variable character_set_server范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 setcollation_serverto specify the collation for the character set.系统变量System Variable character_set_system范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value utf8mb3服务器用于存储标识符的字符集。该值始终为
utf8mb3。The character set used by the server for storing identifiers. The value is alwaysutf8mb3.命令行格式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_VARHint Applies否No 类型Type 目录名称Directory name 安装字符集的目录。请参见第 12.15 节,“字符集配置”。The directory where character sets are installed. See Section 12.15, “Character Set Configuration”.
命令行格式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_VARHint 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 thecheck_proxy_userssystem 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:对于已弃用的
mysql_native_password插件,启用mysql_native_password_proxy_users。For the deprecatedmysql_native_passwordplugin (deprecated), enablemysql_native_password_proxy_users.对于
sha256_password插件(已弃用),启用sha256_password_proxy_users。For thesha256_passwordplugin (deprecated), enablesha256_password_proxy_users.
有关用户代理的信息,请参阅 第 8.2.19 节,“代理用户”。For information about user proxying, see Section 8.2.19, “Proxy Users”.
系统变量System Variable collation_connection范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 连接字符集的排序规则。
collation_connection对字面字符串的比较非常重要。对于与列值的字符串比较,collation_connection并不重要,因为列有自己的排序规则,其排序优先级更高(参见 第 12.8.4 节,“表达式中的排序规则可强制性”)。The collation of the connection character set.collation_connectionis important for comparisons of literal strings. For comparisons of strings with column values,collation_connectiondoes 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_databasecollation_database系统变量System Variable collation_databasecollation_database范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ascollation_server.全局
character_set_database和collation_database系统变量已被弃用;预计将在未来的 MySQL 版本中移除。The globalcharacter_set_databaseandcollation_databasesystem 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 sessioncharacter_set_databaseandcollation_databasesystem 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 forcollation_databaseraises a warning.命令行格式Command-Line Format --collation-server=name系统变量System Variable collation_server范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --completion-type=#系统变量System Variable completion_type范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value NO_CHAINNO_CHAIN有效值Valid Values NO_CHAINNO_CHAINCHAINCHAINRELEASERELEASE012事务完成类型。该变量可以采用下表所示的值。该变量可以使用名称值或相应的整数值进行赋值。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不受影响。这是默认值。COMMITandROLLBACKare unaffected. This is the default value.CHAIN(或 1)CHAIN(or 1)COMMIT和ROLLBACK分别相当于COMMIT AND CHAIN和ROLLBACK AND CHAIN。(新事务会立即开始,并与刚结束事务具有相同的隔离级别。)COMMITandROLLBACKare equivalent toCOMMIT AND CHAINandROLLBACK 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。(事务终止后服务器会断开连接。)COMMITandROLLBACKare equivalent toCOMMIT RELEASEandROLLBACK RELEASE, respectively. (The server disconnects after terminating the transaction.)completion_type影响以START TRANSACTION或BEGIN并以COMMIT或ROLLBACK。它不适用于执行第 15.3.3 节,“导致隐式提交的语句”中列出的语句执行而产生的隐式提交。同样不适用于XA COMMITXA ROLLBACK),或当autocommit=1。completion_typeaffects transactions that begin withSTART TRANSACTIONorBEGINand end withCOMMITorROLLBACK. 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 forXA COMMIT,XA ROLLBACK, or whenautocommit=1.命令行格式Command-Line Format --component-scheduler.enabled[=value]--component-scheduler.enabled[=value]系统变量System Variable component_scheduler.enabled范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON在启动时设置为
OFF时,后台线程不会启动。任务仍然可以被调度,但它们不会运行,直到component_scheduler被启用。在启动时设置为ON时,该组件完全可用。When set toOFFat startup, the background thread does not start. Tasks can still be scheduled, but they do not run untilcomponent_scheduleris enabled. When set toONat startup, the component is fully operational.也可以动态设置该值以获得以下效果:It is also possible to set the value dynamically to get the following effects:
ON启动后台线程,立即开始处理队列。ONstarts the background thread that begins servicing the queue immediately.OFF发出终止后台线程的信号,并等待其结束。后台线程在访问队列以检查要执行的任务之前会检查终止标志。OFFsignals 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.
命令行格式Command-Line Format --concurrent-insert[=value]系统变量System Variable concurrent_insert范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value AUTOAUTO有效值Valid Values NEVERNEVERAUTOAUTOALWAYS总是ALWAYS012如果是
AUTO(默认值),MySQL 允许在MyISAM表中同时运行INSERT和SELECT语句,这些表在数据文件的中间没有空闲块。IfAUTO(the default), MySQL permitsINSERTandSELECTstatements to run concurrently forMyISAMtables 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 forMyISAMtables that do not have holesALWAYS(或 2)ALWAYS(or 2)允许对所有 MyISAM表进行并发插入,即使表中有空洞。对于有空洞的表,如果表正在被另一个线程使用,新行将插入表的末尾。否则,MySQL 将获取正常写锁并将新行插入空洞中。Enables concurrent inserts for allMyISAMtables, 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_insertis set toNEVER.另见 第 10.11.3 节,“并发插入”。See also Section 10.11.3, “Concurrent Inserts”.
命令行格式Command-Line Format --connect-timeout=#系统变量System Variable connect_timeout范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 withBad handshake. The default value is 10 seconds.如果客户端经常遇到类似
connect_timeout的错误,增加Lost connection to MySQL server at 'XXX', system error: errno的值可能会有所帮助。Increasing theconnect_timeoutvalue might help if clients frequently encounter errors of the formLost connection to MySQL server at '.XXX', system error:errno命令行格式Command-Line Format --connection-memory-chunk-size=#系统变量System Variable connection_memory_chunk_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 counterGlobal_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 settingconnection_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 theInnoDBbuffer pool is also not included.您必须拥有
SYSTEM_VARIABLES_ADMIN或SUPER权限才能设置此变量。You must have theSYSTEM_VARIABLES_ADMINorSUPERprivilege to set this variable.命令行格式Command-Line Format --connection-memory-limit=#系统变量System Variable connection_memory_limit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 withER_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 theInnoDBbuffer pool is also not included.您必须拥有
SYSTEM_VARIABLES_ADMIN或SUPER权限才能设置此变量。You must have theSYSTEM_VARIABLES_ADMINorSUPERprivilege to set this variable.系统变量System Variable core_file范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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-fileoption.命令行格式Command-Line Format --create-admin-listener-thread[={OFF|ON}]系统变量System Variable create_admin_listener_thread范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 isOFF; 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将无效,因为在这种情况下,服务器不会维护任何管理网络接口。Settingcreate_admin_listener_threadhas no effect ifadmin_addressis not specified because in that case the server maintains no administrative network interface.命令行格式Command-Line Format --cte-max-recursion-depth=#系统变量System Variable cte_max_recursion_depth范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --datadir=dir_name--datadir=dir_name系统变量System Variable datadir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 thedatadirvalue as an absolute path.命令行格式Command-Line Format --debug[=debug_options]--debug[=debug_options]系统变量System Variable debugdebug范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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--debugoption 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”.
系统变量System Variable debug_sync范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 此变量是调试同步功能的用户界面。使用调试同步功能要求 MySQL 使用
-DWITH_DEBUG=ONCMake 选项进行配置(参见 第 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=ONCMake 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=启动,其中NN是大于 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 ofdebug_syncisOFF. If the server is started with--debug-sync-timeout=, whereNNis a timeout value greater than 0, Debug Sync is enabled and the value ofdebug_syncisON - current signalfollowed by the signal name. Also,Nbecomes 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.
系统变量System Variable default_collation_for_utf8mb4范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value utf8mb4_0900_ai_ciutf8mb4_0900_ai_ci有效值Valid Values utf8mb4_0900_ai_ciutf8mb4_0900_ai_ciutf8mb4_general_ciImportantdefault_collation_for_utf8mb4系统变量仅供 MySQL 复制内部使用。Thedefault_collation_for_utf8mb4system 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 theutf8mb4character 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 forutf8mb4. 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 forutf8mb4in MySQL 5.7 isutf8mb4_general_ci, bututf8mb4_0900_ai_ciin 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 collationutf8mb4_general_ci.以下语句中使用默认的
utf8mb4排序规则:The defaultutf8mb4collation is used in the following statements:SHOW COLLATION和SHOW CHARACTER SET。SHOW COLLATIONandSHOW CHARACTER SET.CREATE TABLE和ALTER TABLE中有CHARACTER SET utf8mb4子句但没有COLLATION子句,无论是针对表的字符集还是列的字符集。CREATE TABLEandALTER TABLEhaving aCHARACTER SET utf8mb4clause without aCOLLATIONclause, either for the table character set or for a column character set.CREATE DATABASE和ALTER DATABASE包含CHARACTER SET utf8mb4子句但没有COLLATION子句。CREATE DATABASEandALTER DATABASEhaving aCHARACTER SET utf8mb4clause without aCOLLATIONclause.任何包含形式为
_utf8mb4'some text'的字符串字面值且没有COLLATE子句的语句。Any statement containing a string literal of the form_utf8mb4'without asome text'COLLATEclause.
另请参见 第 12.9 节,“Unicode 支持”。See also Section 12.9, “Unicode Support”.
命令行格式Command-Line Format --default-password-lifetime=#系统变量System Variable default_password_lifetime范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 defaultdefault_password_lifetimevalue is 0, which disables automatic password expiration. If the value ofdefault_password_lifetimeis a positive integerN, it indicates the permitted password lifetime; passwords must be changed everyNdays.可以使用
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 theCREATE USERandALTER USERstatements. See Section 8.2.15, “Password Management”.命令行格式Command-Line Format --default-storage-engine=name系统变量System Variable default_storage_engine范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 forTEMPORARYtables, set thedefault_tmp_storage_enginesystem variable.要查看哪些存储引擎可用和启用,请使用
SHOW ENGINES语句或查询INFORMATION_SCHEMAENGINES表。To see which storage engines are available and enabled, use theSHOW ENGINESstatement or query theINFORMATION_SCHEMAENGINEStable.如果在服务器启动时禁用默认存储引擎,必须为永久表和
TEMPORARY表设置不同的默认引擎,否则服务器无法启动。If you disable the default storage engine at server startup, you must set the default engine for both permanent andTEMPORARYtables to a different engine, or else the server does not start.命令行格式Command-Line Format --default-table-encryption[={OFF|ON}]系统变量System Variable default_table_encryption范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 anENCRYPTIONclause.default_table_encryption变量仅适用于用户创建的模式和通用表空间。它不管理mysql系统表空间的加密。Thedefault_table_encryptionvariable is only applicable to user-created schemas and general tablespaces. It does not govern encryption of themysqlsystem tablespace.设置
default_table_encryption的运行时值需要SYSTEM_VARIABLES_ADMIN和TABLE_ENCRYPTION_ADMIN权限,或者已弃用的SUPER权限。Setting the runtime value ofdefault_table_encryptionrequires theSYSTEM_VARIABLES_ADMINandTABLE_ENCRYPTION_ADMINprivileges, or the deprecatedSUPERprivilege.在 Group Replication 运行时,
default_table_encryption的值无法更改。The value ofdefault_table_encryptioncannot be changed while Group Replication is running.default_table_encryption支持SET PERSIST和SET PERSIST_ONLY语法。参见 第 7.1.9.3 节,“持久化系统变量”。default_table_encryptionsupportsSET PERSISTandSET PERSIST_ONLYsyntax. See Section 7.1.9.3, “Persisted System Variables”.更多信息,请参见 为模式和通用表空间定义加密默认值。For more information, see Defining an Encryption Default for Schemas and General Tablespaces.
命令行格式Command-Line Format --default-tmp-storage-engine=name系统变量System Variable default_tmp_storage_engine范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 枚举Enumeration 默认值Default Value InnoDBTEMPORARY表(使用CREATE TEMPORARY TABLE创建)的默认存储引擎。要设置永久表的存储引擎,请设置default_storage_engine系统变量。另请参阅该变量的讨论以了解可能的取值。The default storage engine forTEMPORARYtables (created withCREATE TEMPORARY TABLE). To set the storage engine for permanent tables, set thedefault_storage_enginesystem 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 andTEMPORARYtables to a different engine, or else the server does not start.命令行格式Command-Line Format --default-week-format=#系统变量System Variable default_week_format范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 7的默认模式值
WEEK()函数。请参见第 14.7 节,“日期和时间函数”.The default mode value to use for theWEEK()function. See Section 14.7, “Date and Time Functions”.命令行格式Command-Line Format --delay-key-write[={OFF|ON|ALL}]系统变量System Variable delay_key_write范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value ONON有效值Valid Values OFFOFFONONALLALL该变量指定如何使用延迟键写入。它仅适用于
MyISAM表。延迟键写入会导致键缓冲区在写入之间不被刷新。另请参阅18.2.1 节,“MyISAM 启动选项”。This variable specifies how to use delayed key writes. It applies only toMyISAMtables. 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 theDELAY_KEY_WRITEtable option that can be used inCREATE TABLEstatements.选项Option 说明Description OFFOFFDELAY_KEY_WRITE被忽略。DELAY_KEY_WRITEis ignored.ONONMySQL 会遵循在 CREATE TABLE语句中指定的任何DELAY_KEY_WRITE选项。这是默认值。MySQL honors anyDELAY_KEY_WRITEoption specified inCREATE TABLEstatements. This is the default value.ALLALL所有新打开的表都被视为已启用 DELAY_KEY_WRITE选项创建。All new opened tables are treated as if they were created with theDELAY_KEY_WRITEoption enabled.Note如果您将此变量设置为
ALL,则在表正在使用时不应从其他程序(例如另一个 MySQL 服务器或 myisamchk)使用MyISAM表。这样做会导致索引损坏。If you set this variable toALL, you should not useMyISAMtables 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 启动选项”。IfDELAY_KEY_WRITEis 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 allMyISAMtables by starting the server with themyisam_recover_optionssystem 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_writeis set toOFF.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.命令行格式Command-Line Format --delayed-insert-limit=#已弃用Deprecated 是Yes 系统变量System Variable delayed_insert_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 (becauseDELAYEDinserts are not supported), and you should expect it to be removed in a future release.命令行格式Command-Line Format --delayed-insert-timeout=#已弃用Deprecated 是Yes 系统变量System Variable delayed_insert_timeout范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 300最小值Minimum Value 1最大值Maximum Value 31536000单位Unit 秒seconds 该系统变量已被弃用(因为不支持
DELAYED插入),您应该预期它将在未来的版本中被移除。This system variable is deprecated (becauseDELAYEDinserts are not supported), and you should expect it to be removed in a future release.命令行格式Command-Line Format --delayed-queue-size=#已弃用Deprecated 是Yes 系统变量System Variable delayed_queue_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 (becauseDELAYEDinserts are not supported), and you should expect it to be removed in a future release.命令行格式Command-Line Format --disabled-storage-engines=engine[,engine]...系统变量System Variable disabled_storage_engines范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 newMyISAMorFEDERATEDtables 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_enginesis 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 withCREATE TABLEorCREATE TABLESPACE, and cannot be used withALTER TABLE ... ENGINEorALTER TABLESPACE ... ENGINEto change the storage engine of existing tables or tablespaces. Attempts to do so result in anER_DISABLED_STORAGE_ENGINEerror.disabled_storage_engines不限制现有表的其他 DDL 语句,例如CREATE INDEX,TRUNCATE TABLE,ANALYZE TABLE,DROP TABLE,或DROP TABLESPACE。这允许平稳过渡,使使用禁用引擎的现有表或表空间可以通过例如ALTER TABLE ... ENGINE.permitted_enginedisabled_storage_enginesdoes not restrict other DDL statements for existing tables, such asCREATE INDEX,TRUNCATE TABLE,ANALYZE TABLE,DROP TABLE, orDROP 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 asALTER TABLE ... ENGINE.permitted_engine允许将
default_storage_engine或default_tmp_storage_engine系统变量设置为已禁用的存储引擎。这可能导致应用程序行为异常或失败,尽管在开发环境中这可能是一个有用的技术,用于识别使用已禁用引擎的应用程序,以便对其进行修改。It is permitted to set thedefault_storage_engineordefault_tmp_storage_enginesystem 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_enginesis 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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON此变量控制服务器如何处理密码已过期的客户端:This variable controls how the server handles clients with expired passwords:
如果客户端表明它可以处理过期密码,则
disconnect_on_expired_password的值无关紧要。服务器允许客户端连接,但会将其置于沙箱模式。If the client indicates that it can handle expired passwords, the value ofdisconnect_on_expired_passwordis irrelevant. The server permits the client to connect but puts it in sandbox mode.如果客户端未表明它可以处理过期密码,服务器将根据
disconnect_on_expired_password的值来处理客户端:If the client does not indicate that it can handle expired passwords, the server handles the client according to the value ofdisconnect_on_expired_password:如果启用了
disconnect_on_expired_password,服务器将断开客户端连接。Ifdisconnect_on_expired_password: is enabled, the server disconnects the client.如果
disconnect_on_expired_password被禁用,服务器允许客户端连接,但会将其置于沙箱模式。Ifdisconnect_on_expired_password: is disabled, the server permits the client to connect but puts it in sandbox mode.
有关客户端和服务器设置在处理过期密码方面的交互的更多信息,请参见 第 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”.
命令行格式Command-Line Format --div-precision-increment=#系统变量System Variable div_precision_increment范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_VARHint 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 thelog_filter_dragneterror log filter component. Iflog_filter_dragnetis not installed,dragnet.log_error_filter_rulesis unavailable. Iflog_filter_dragnetis installed but not enabled, changes todragnet.log_error_filter_ruleshave no effect.默认值的效果类似于使用设置为
log_error_verbosity=2的log_sink_internal过滤器执行的过滤操作。The effect of the default value is similar to the filtering performed by thelog_sink_internalfilter with a setting oflog_error_verbosity=2.可以查询
dragnet.Status状态变量,以确定最近一次对dragnet.log_error_filter_rules的赋值结果。dragnet.Statusstatus variable can be consulted to determine the result of the most recent assignment todragnet.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_VARHint 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 componentcomponent_enterprise_encryptionis 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_VARHint 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 oldopenssl_udfshared 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 oldopenssl_udfshared library functions, you must set the system variable padding toON. WhenONis 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 theopenssl_udfshared library functions). WhenOFFis 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.命令行格式Command-Line Format --end-markers-in-json[={OFF|ON}]系统变量System Variable end_markers_in_json范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --eq-range-index-dive-limit=#系统变量System Variable eq_range_index_dive_limit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 upcol_namevalues:col_nameIN(val1, ...,valN)col_name=val1OR ... ORcol_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 containsNequality ranges. The optimizer can make row estimates using index dives or index statistics. Ifeq_range_index_dive_limitis greater than 0, the optimizer uses existing index statistics instead of index dives if there areeq_range_index_dive_limitor more equality ranges. Thus, to permit use of index dives for up toNequality ranges, seteq_range_index_dive_limittoN+ 1. To disable use of index statistics and always use index dives regardless ofN, seteq_range_index_dive_limitto 0.欲了解更多信息,请参见 多值比较的相等范围优化。For more information, see Equality Range Optimization of Many-Valued Comparisons.
要更新表索引统计以获得最佳估计,请使用
ANALYZE TABLE。To update table index statistics for best estimates, useANALYZE TABLE.上一个生成消息的语句导致的错误数量。此变量为只读。请参见 第 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_schedulerevent_scheduler命令行格式Command-Line Format --event-scheduler[=value]--event-scheduler[=value]系统变量System Variable event_schedulerevent_scheduler范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value ONON有效值Valid Values ONONOFFOFFDISABLEDDISABLED该变量用于启用或禁用事件调度器,并启动或停止事件调度器。可能的状态值为
ON、OFF和DISABLED。将事件调度器设置为OFF不等同于禁用事件调度器,禁用事件调度器需要将状态设置为DISABLED。关于此变量及其对事件调度器操作的影响,可以在第 27.4.2 节,“事件调度器配置”中找到更详细的讨论This variable enables or disables, and starts or stops, the Event Scheduler. The possible status values areON,OFF, andDISABLED. Turning the Event SchedulerOFFis not the same as disabling the Event Scheduler, which requires setting the status toDISABLED. This variable and its effects on the Event Scheduler's operation are discussed in greater detail in Section 27.4.2, “Event Scheduler Configuration”命令行格式Command-Line Format --explain-format=format--explain-format=format系统变量System Variable explain_formatexplain_format范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value TRADITIONALTRADITIONAL有效值Valid Values TRADITIONALTRADITIONALJSONTREETREE该变量决定在显示查询执行计划时,如果没有
FORMAT选项,EXPLAIN使用的默认输出格式。可能的值及其效果列在此处:This variable determines the default output format used byEXPLAINin the absence of aFORMAToption 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 ifFORMAT=TRADITIONALhad been specified as part of theEXPLAINstatement. This is the variable's default value.DEFAULTis also supported as a synonym forTRADITIONAL, and has exactly the same effect.NoteDEFAULT不能用作EXPLAIN语句的FORMAT选项的一部分。DEFAULTcannot be used as part of anEXPLAINstatement'sFORMAToption.JSON:使用 JSON 输出格式,就好像指定了FORMAT=JSON。JSON: Use the JSON output format, as ifFORMAT=JSONhad been specified.TREE:使用基于树的输出格式,就好像指定了FORMAT=TREE。TREE: Use the tree-based output format, as ifFORMAT=TREEhad been specified.
此变量的设置还会影响
EXPLAIN ANALYZE。因此,DEFAULT和TRADITIONAL被解释为TREE。如果explain_format的值为JSON,且执行没有FORMAT选项的EXPLAIN ANALYZE语句,则该语句会报错(ER_NOT_SUPPORTED_YET)。The setting for this variable also affectsEXPLAIN ANALYZE. For this purpose,DEFAULTandTRADITIONALare interpeted asTREE. If the value ofexplain_formatisJSONand anEXPLAIN ANALYZEstatement having noFORMAToption is issued, the statement raises an error (ER_NOT_SUPPORTED_YET).在
EXPLAIN或EXPLAIN ANALYZE中使用格式说明符会覆盖explain_format的任何设置。Using a format specifier withEXPLAINorEXPLAIN ANALYZEoverrides any setting forexplain_format.explain_format系统变量在使用此语句显示表列信息时,对EXPLAIN输出没有影响。Theexplain_formatsystem variable has no effect onEXPLAINoutput 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 ofexplain_formatrequires no special privileges; setting it on the global level requiresSYSTEM_VARIABLES_ADMIN(or the deprecatedSUPERprivilege). See Section 7.1.9.1, “System Variable Privileges”.有关详细信息和示例,请参阅获取执行计划信息。For more information and examples, see Obtaining Execution Plan Information.
命令行格式Command-Line Format --explain-json-format-version=#系统变量System Variable explain_json_format_version范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 byEXPLAIN FORMAT=JSONstatements. Setting this variable to1causes 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. Settingexplain_json_format_versionto2causes 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_VARHint 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 andNULL-value handling inTIMESTAMPcolumns. By default,explicit_defaults_for_timestampis enabled, which disables the nonstandard behaviors. Disablingexplicit_defaults_for_timestampresults in a warning.如果
explicit_defaults_for_timestamp被禁用,服务器将启用非标准行为,并按以下方式处理TIMESTAMP列:Ifexplicit_defaults_for_timestampis disabled, the server enables the nonstandard behaviors and handlesTIMESTAMPcolumns as follows:TIMESTAMP列如果没有显式声明NULL属性,则会自动声明为NOT NULL属性。向此类列赋值NULL是允许的,并会将该列设置为当前时间戳。例外:尝试将NULL插入声明为TIMESTAMP NOT NULL的生成列时,会报错。TIMESTAMPcolumns not explicitly declared with theNULLattribute are automatically declared with theNOT NULLattribute. Assigning such a column a value ofNULLis permitted and sets the column to the current timestamp. Exception: Attempting to insertNULLinto a generated column declared asTIMESTAMP NOT NULLis rejected with an error.表中的第一个
TIMESTAMP列,如果没有显式声明NULL属性,或者显式声明DEFAULT或ON UPDATE属性,将自动声明为DEFAULT CURRENT_TIMESTAMP和ON UPDATE CURRENT_TIMESTAMP属性。The firstTIMESTAMPcolumn in a table, if not explicitly declared with theNULLattribute or an explicitDEFAULTorON UPDATEattribute, is automatically declared with theDEFAULT CURRENT_TIMESTAMPandON UPDATE CURRENT_TIMESTAMPattributes.TIMESTAMP列在第一个之后,如果没有显式声明NULL属性或显式的DEFAULT属性,则会自动声明为DEFAULT '0000-00-00 00:00:00'(即 “零” 时间戳)。对于插入的行,如果没有为该列指定显式值,则该列将被分配'0000-00-00 00:00:00',且不会发生警告。TIMESTAMPcolumns following the first one, if not explicitly declared with theNULLattribute or an explicitDEFAULTattribute, are automatically declared asDEFAULT '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_DATESQL 模式,默认值'0000-00-00 00:00:00'可能无效。请注意,TRADITIONALSQL 模式包括严格模式和NO_ZERO_DATE。参见 第 7.1.11 节,“服务器 SQL 模式”。Depending on whether strict SQL mode or theNO_ZERO_DATESQL mode is enabled, a default value of'0000-00-00 00:00:00'may be invalid. Be aware that theTRADITIONALSQL mode includes strict mode andNO_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列的处理方式如下:Ifexplicit_defaults_for_timestampis enabled, the server disables the nonstandard behaviors and handlesTIMESTAMPcolumns as follows:不可能将
TIMESTAMP列赋值为NULL来设置为当前时间戳。要分配当前时间戳,请将该列设置为CURRENT_TIMESTAMP或其同义词,例如NOW()。It is not possible to assign aTIMESTAMPcolumn a value ofNULLto set it to the current timestamp. To assign the current timestamp, set the column toCURRENT_TIMESTAMPor a synonym such asNOW().TIMESTAMP列如果没有明确声明NOT NULL属性,将自动声明为NULL属性,并允许NULL值。给这样的列赋值为NULL会将其设置为NULL,而不是当前时间戳。TIMESTAMPcolumns not explicitly declared with theNOT NULLattribute are automatically declared with theNULLattribute and permitNULLvalues. Assigning such a column a value ofNULLsets it toNULL, not the current timestamp.TIMESTAMP列如果声明了NOT NULL属性,则不允许NULL值。对于插入操作,如果指定NULL给此类列,在启用严格 SQL 模式下的单行插入会导致错误;在禁用严格 SQL 模式的多行插入中,则插入'0000-00-00 00:00:00'。无论如何,将该列赋值为NULL都不会将其设置为当前时间戳。TIMESTAMPcolumns declared with theNOT NULLattribute do not permitNULLvalues. For inserts that specifyNULLfor 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 ofNULLset it to the current timestamp.TIMESTAMP列如果显式声明了NOT NULL属性且未显式声明DEFAULT属性,则被视为没有默认值。对于插入的新行,如果未为此类列指定显式值,结果取决于 SQL 模式。如果启用了严格 SQL 模式,将发生错误。如果未启用严格 SQL 模式,该列将使用隐式默认值'0000-00-00 00:00:00'并会生成警告。这与 MySQL 对其他时间类型(如DATETIME)的处理方式类似。TIMESTAMPcolumns explicitly declared with theNOT NULLattribute and without an explicitDEFAULTattribute 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 asDATETIME.没有
TIMESTAMP列会自动声明为DEFAULT CURRENT_TIMESTAMP或ON UPDATE CURRENT_TIMESTAMP属性。这些属性必须明确指定。NoTIMESTAMPcolumn is automatically declared with theDEFAULT CURRENT_TIMESTAMPorON UPDATE CURRENT_TIMESTAMPattributes. Those attributes must be explicitly specified.表中的第一个
TIMESTAMP列与后续的TIMESTAMP列没有区别。The firstTIMESTAMPcolumn in a table is not handled differently fromTIMESTAMPcolumns following the first one.
如果在服务器启动时禁用了
explicit_defaults_for_timestamp,错误日志中会出现此警告:Ifexplicit_defaults_for_timestampis 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 theexplicit_defaults_for_timestampsystem variable at server startup.Noteexplicit_defaults_for_timestamp本身也已被弃用,因为它的唯一目的是允许控制将在未来 MySQL 版本中移除的已弃用TIMESTAMP行为。当这些行为被移除时,预计explicit_defaults_for_timestamp也将被移除。explicit_defaults_for_timestampis itself deprecated because its only purpose is to permit control over deprecatedTIMESTAMPbehaviors that are to be removed in a future MySQL release. When removal of those behaviors occurs, expectexplicit_defaults_for_timestampto 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”.
系统变量System Variable external_user范围Scope 会议Session 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 isNULL. See Section 8.2.19, “Proxy Users”.命令行格式Command-Line Format --flush[={OFF|ON}]系统变量System Variable flush范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF仅适用于 MyISAM。Applies to MyISAM, only.
如果
ON,服务器将在每条 SQL 语句之后将所有更改刷新(同步)到磁盘。通常,MySQL 仅在每条 SQL 语句之后将所有更改写入磁盘,并让操作系统处理磁盘的同步。参见 B.3.3.3 节,“如果 MySQL 不断崩溃该怎么办”。如果你使用 mysqld 并带上--flush选项启动,则此变量被设置为ON。IfON, 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 toONif you start mysqld with the--flushoption.Note如果
flush已启用,flush_time的值无关紧要,对flush_time的更改不会影响刷新行为。Ifflushis enabled, the value offlush_timedoes not matter and changes toflush_timehave no effect on flush behavior.命令行格式Command-Line Format --flush-time=#系统变量System Variable flush_time范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 everyflush_timeseconds 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的更改不会影响刷新行为。Ifflushis enabled, the value offlush_timedoes not matter and changes toflush_timehave no effect on flush behavior.系统变量System Variable foreign_key_checks范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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, anALTER TABLEoperation 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 onNDBtables as it does forInnoDBtables. Typically you leave this setting enabled during normal operation, to enforce referential integrity. Disabling foreign key checking can be useful for reloadingInnoDBtables 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会删除被其他表引用外键的表。Settingforeign_key_checksto 0 also affects data definition statements:DROP SCHEMAdrops a schema even if it contains tables that have foreign keys that are referred to by tables outside the schema, andDROP TABLEdrops tables that have foreign keys that are referred to by other tables.Note将
foreign_key_checks设置为 1 不会触发对现有表数据的扫描。因此,在foreign_key_checks = 0时添加到表的行不会进行一致性验证。Settingforeign_key_checksto 1 does not trigger a scan of the existing table data. Therefore, rows added to the table whileforeign_key_checks = 0are not verified for consistency.不允许删除被外键约束使用的索引,即使设置了
foreign_key_checks=0。必须先删除外键约束,然后才能删除索引。Dropping an index required by a foreign key constraint is not permitted, even withforeign_key_checks=0. The foreign key constraint must be removed before dropping the index.命令行格式Command-Line Format --ft-boolean-syntax=name系统变量System Variable ft_boolean_syntax范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value + -><()~*:""&|使用
IN BOOLEAN MODE进行布尔全文搜索所支持的运算符列表。请参阅 第 14.9.2 节,“布尔全文搜索”。The list of operators supported by boolean full-text searches performed usingIN 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.
命令行格式Command-Line Format --ft-max-word-len=#系统变量System Variable ft_max_word_len范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 84最小值Minimum Value 10最大值Maximum Value 84要包含在
MyISAMFULLTEXT索引中的最大单词长度。The maximum length of the word to be included in aMyISAMFULLTEXTindex.Note更改此变量后,必须重建
MyISAM表上的FULLTEXT索引。使用REPAIR TABLE tbl_name QUICK。FULLTEXTindexes onMyISAMtables must be rebuilt after changing this variable. UseREPAIR TABLE.tbl_nameQUICK命令行格式Command-Line Format --ft-min-word-len=#系统变量System Variable ft_min_word_len范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 4最小值Minimum Value 1最大值Maximum Value 82要包含在
MyISAMFULLTEXT索引中的单词的最小长度。The minimum length of the word to be included in aMyISAMFULLTEXTindex.Note更改此变量后,必须重建
MyISAM表上的FULLTEXT索引。使用REPAIR TABLE tbl_name QUICK。FULLTEXTindexes onMyISAMtables must be rebuilt after changing this variable. UseREPAIR TABLE.tbl_nameQUICK命令行格式Command-Line Format --ft-query-expansion-limit=#系统变量System Variable ft_query_expansion_limit范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 usingWITH QUERY EXPANSION.命令行格式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_VARHint 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 onMyISAMtables. 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 thestorage/myisam/ft_static.cfile). Setting this variable to the empty string ('') disables stopword filtering. See also Section 14.9.4, “Full-Text Stopwords”.NoteFULLTEXT索引在MyISAM表上更改此变量或停止词文件内容后必须重建。使用REPAIR TABLE tbl_name QUICK。FULLTEXTindexes onMyISAMtables must be rebuilt after changing this variable or the contents of the stopword file. UseREPAIR TABLE.tbl_nameQUICK命令行格式Command-Line Format --general-log[={OFF|ON}]--general-log[={OFF|ON}]系统变量System Variable general_log范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 (orOFF) to disable the log or 1 (orON) to enable the log. The destination for log output is controlled by thelog_outputsystem variable; if that value isNONE, no log entries are written even if the log is enabled.命令行格式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_VARHint 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, but the initial value can be changed with thehost_name.log--general_log_fileoption.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_VARHint 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 forCREATE USER,ALTER USER, andSET PASSWORDstatements. 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_VARHint 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_memoryshould not exceed this amount. Any time that it does, all queries (including any currently running) from regular users are rejected withER_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 theInnoDBbuffer pool is excluded from the total.您必须拥有
SYSTEM_VARIABLES_ADMIN或SUPER权限才能设置此变量。You must have theSYSTEM_VARIABLES_ADMINorSUPERprivilege 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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value FALSE确定服务器是否计算
Global_connection_memory。此变量必须显式启用,否则不会执行内存计算,并且Global_connection_memory不会被设置。Determines whether the server calculatesGlobal_connection_memory. This variable must be enabled explicitly; otherwise, the memory calculation is not performed, andGlobal_connection_memoryis not set.您必须拥有
SYSTEM_VARIABLES_ADMIN或SUPER权限才能设置此变量。You must have theSYSTEM_VARIABLES_ADMINorSUPERprivilege to set this variable.命令行格式Command-Line Format --group-concat-max-len=#系统变量System Variable group_concat_max_len范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 整数Integer 默认值Default Value 1024最小值Minimum Value 4最大值(64 位平台)Maximum Value (64-bit platforms) 18446744073709551615最大值(32 位平台)Maximum Value (32-bit platforms) 4294967295GROUP_CONCAT()函数允许的最大结果长度(以字节为单位)。默认值为 1024。The maximum permitted result length in bytes for theGROUP_CONCAT()function. The default is 1024.Important在为
group_concat_max_len设置值时,请考虑以下内容:When setting the value forgroup_concat_max_len, consider the following:估算
GROUP_CONCAT()输出所需的最大长度,并相应地设置该值。Estimate the maximum length required forGROUP_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.
如果服务器可以使用
zlib压缩库,则为YES,如果不能,则为NO。如果不能,COMPRESS()和UNCOMPRESS()函数不能使用。YESif thezlibcompression library is available to the server,NOif not. If not, theCOMPRESS()andUNCOMPRESS()functions cannot be used.YES如果 mysqld 支持插件的动态加载,NO如果不支持。如果值为NO,则无法使用诸如--plugin-load之类的选项在服务器启动时加载插件,或使用INSTALL PLUGIN语句在运行时加载插件。YESif mysqld supports dynamic loading of plugins,NOif not. If the value isNO, you cannot use options such as--plugin-loadto load plugins at server startup, or theINSTALL PLUGINstatement to load plugins at runtime.YES如果服务器支持空间数据类型,NO如果不支持。YESif the server supports spatial data types,NOif not.如果存在语句分析功能,则为
YES;如果不存在,则为NO。如果存在,profiling系统变量控制此功能是启用还是禁用。请参见第 15.7.7.33 节,“SHOW PROFILES 语句”。YESif statement profiling capability is present,NOif not. If present, theprofilingsystem 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已弃用,总是具有NO的值,并且您应预期它将在未来的 MySQL 版本中被移除。have_query_cacheis deprecated, always has a value ofNO, and you should expect it to be removed in a future MySQL release.YES表示RTREE索引可用,NO表示不可用。(这些用于MyISAM表中的空间索引。)YESifRTREEindexes are available,NOif not. (These are used for spatial indexes inMyISAMtables.)系统变量System Variable have_statement_timeout范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 语句执行超时功能是否可用(参见 语句执行时间优化器提示)。如果此功能使用的后台线程无法初始化,则该值可能为
NO。Whether the statement execution timeout feature is available (see Statement Execution Time Optimizer Hints). The value can beNOif the background thread used by this feature could not be initialized.YES如果启用了符号链接支持,NO如果没有。在 Unix 系统上这是支持DATA DIRECTORY和INDEX DIRECTORY表选项所必需的。如果服务器使用--skip-symbolic-links选项启动,则值为DISABLED。YESif symbolic link support is enabled,NOif not. This is required on Unix for support of theDATA DIRECTORYandINDEX DIRECTORYtable options. If the server is started with the--skip-symbolic-linksoption, the value isDISABLED.这个变量在 Windows 上没有意义。This variable has no meaning on Windows.
Note符号链接支持,以及控制它的
--symbolic-links选项已被弃用;预计将在未来的 MySQL 版本中删除。此外,该选项默认被禁用。相关的have_symlink系统变量也已被弃用,您应该预计它将在未来的 MySQL 版本中被删除。Symbolic link support, along with the--symbolic-linksoption 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 relatedhave_symlinksystem 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_VARHint 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”.
命令行格式Command-Line Format --host-cache-size=#系统变量System Variable host_cache_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value -1(表示自动调整大小;不要分配此字面值)-1(signifies autosizing; do not assign this literal value)最小值Minimum Value 0最大值Maximum Value 65536MySQL 服务器维护了一个内存中的主机缓存,其中包含客户端主机名和 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会产生以下效果:Thehost_cache_sizevariable controls the size of the host cache, as well as the size of the Performance Schemahost_cachetable that exposes the cache contents. Settinghost_cache_sizehas 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 thehost_cachetable, 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 ofmax_connectionsup to 500, plus 1 for every increment of 20 over 500 in themax_connectionsvalue, capped to a limit of 2000.系统变量System Variable hostnamehostname范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 服务器在启动时将此变量设置为服务器主机名。最大长度为 255 个字符。The server sets this variable to the server host name at startup. The maximum length is 255 characters.
这个变量是
last_insert_id变量的同义词。它的存在是为了与其他数据库系统兼容。你可以使用SELECT @@identity来读取其值,并使用SET identity来设置它。This variable is a synonym for thelast_insert_idvariable. It exists for compatibility with other database systems. You can read its value withSELECT @@identity, and set it usingSET identity.命令行格式Command-Line Format --init-connect=name系统变量System Variable init_connect范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_ADMINprivilege (or the deprecatedSUPERprivilege), the content ofinit_connectis not executed. This is done so that an erroneous value forinit_connectdoes 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 executinginit_connectfor users that have theCONNECTION_ADMIN或者SUPERprivilege enables them to open a connection and fix theinit_connectvalue.For users that have theCONNECTION_ADMINprivilege (or the deprecatedSUPERprivilege), the content ofinit_connectis not executed. This is done so that an erroneous value forinit_connectdoes 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 executinginit_connectfor users that have theCONNECTION_ADMINorSUPERprivilege enables them to open a connection and fix theinit_connectvalue.init_connect的执行会被跳过,如果客户端用户的密码已过期。这样做的原因是此类用户无法执行任意语句,因此init_connect执行会失败,导致客户端无法连接。跳过init_connect的执行可以让用户连接并更改密码。init_connectexecution is skipped for any client user with an expired password. This is done because such a user cannot execute arbitrary statements, and thusinit_connectexecution fails, leaving the client unable to connect. Skippinginit_connectexecution enables the user to connect and change password.服务器会丢弃由
init_connect值中的语句产生的任何结果集。The server discards any result sets produced by statements in the value ofinit_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_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 86400最小值Minimum Value 0最大值Maximum Value 31536000单位Unit 秒seconds 一些
INFORMATION_SCHEMA表包含提供表统计信息的列:SomeINFORMATION_SCHEMAtables 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 themysql.index_statsandmysql.table_statsdictionary 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 themysql.index_statsandmysql.table_statsdictionary tables. Subsequent queries retrieve the cached statistics until the cached statistics expire. A server restart or the first opening of themysql.index_statsandmysql.table_statstables do not update cached statistics automatically.information_schema_stats_expiry会话变量定义了缓存统计数据过期的时间周期。默认值为 86400 秒(24 小时),但该时间周期可以延长至最多一年。Theinformation_schema_stats_expirysession 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, useANALYZE TABLE.要始终直接从存储引擎获取最新的统计信息并绕过缓存值,请将
information_schema_stats_expiry设置为0。To always retrieve the latest statistics directly from the storage engine and bypass cached values, setinformation_schema_stats_expiryto0.在以下情况下查询统计信息列不会在
mysql.index_stats和mysql.table_stats字典表中存储或更新统计信息:Querying statistics columns does not store or update statistics in themysql.index_statsandmysql.table_statsdictionary tables under these circumstances:当缓存的统计信息未过期时。When cached statistics have not expired.
当
information_schema_stats_expiry设置为 0 时。Wheninformation_schema_stats_expiryis set to 0.当服务器处于
read_only、super_read_only、transaction_read_only或innodb_read_only模式时。When the server is inread_only,super_read_only,transaction_read_only, orinnodb_read_onlymode.当查询也获取性能模式数据时。When the query also fetches Performance Schema data.
在多语句事务期间,统计缓存可能会被更新,此时尚未确定事务是否提交。因此,缓存中可能包含与已知提交状态不对应的信息。这可能发生在
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 withautocommit=0or afterSTART TRANSACTION.information_schema_stats_expiry是一个会话变量,每个客户端会话可以定义自己的过期值。从存储引擎检索并由一个会话缓存的统计信息对其他会话也是可用的。information_schema_stats_expiryis 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”.
命令行格式Command-Line Format --init-file=file_name--init-file=file_name系统变量System Variable init_file范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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--initializeor--initialize-insecureoption, 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 asCREATE USERorGRANT), 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 assql_mode,character_set_server,collation_server,completion_type,explicit_defaults_for_timestamp, anddefault_table_encryption.这些线程也用于执行在启动服务器时通过
init_file指定的任何文件中的语句,因此这些语句会使用服务器内置的系统变量默认值执行。These threads are also used to execute the statements in any file specified withinit_filewhen starting the server, so such statements execute with the server's built-in default values for those system variables.innodb_xxxInnoDB系统变量列在 第 17.14 节,“InnoDB 启动选项和系统变量” 中。这些变量控制InnoDB表的存储、内存使用和 I/O 模式的许多方面,并且由于InnoDB现在是默认的存储引擎,这些变量尤其重要。InnoDBsystem 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 forInnoDBtables, and are especially important now thatInnoDBis the default storage engine.在使用以下
INSERT或ALTER TABLE语句插入AUTO_INCREMENT值时要使用的值。这主要用于二进制日志。The value to be used by the followingINSERTorALTER TABLEstatement when inserting anAUTO_INCREMENTvalue. This is mainly used with the binary log.命令行格式Command-Line Format --interactive-timeout=#系统变量System Variable interactive_timeout范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theCLIENT_INTERACTIVEoption tomysql_real_connect(). See alsowait_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_VARHint Applies是Yes 类型Type 枚举Enumeration 默认值Default Value TempTableTempTable有效值Valid Values MEMORYMEMORYTempTableTempTable用于内存中内部临时表的存储引擎(参见 第 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 areTempTable(the default) andMEMORY.优化器 使用由
internal_tmp_mem_storage_engine定义的存储引擎来处理内存中的内部临时表。The optimizer uses the storage engine defined byinternal_tmp_mem_storage_enginefor in-memory internal temporary tables.配置
internal_tmp_mem_storage_engine的会话设置需要SESSION_VARIABLES_ADMIN或SYSTEM_VARIABLES_ADMIN权限。Configuring a session setting forinternal_tmp_mem_storage_enginerequires theSESSION_VARIABLES_ADMINorSYSTEM_VARIABLES_ADMINprivilege.命令行格式Command-Line Format --join-buffer-size=#系统变量System Variable join_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofjoin_buffer_sizeto 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 forjoin_buffer_sizeis 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 aSET_VARoptimizer 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 ofjoin_buffer_sizedefines 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”.
命令行格式Command-Line Format --keep-files-on-create[={OFF|ON}]系统变量System Variable keep_files_on_create范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 aMyISAMtable is created with noDATA DIRECTORYoption, the.MYDfile is created in the database directory. By default, ifMyISAMfinds an existing.MYDfile in this case, it overwrites it. The same applies to.MYIfiles for tables created with noINDEX DIRECTORYoption. To suppress this behavior, set thekeep_files_on_createvariable toON(1), in which caseMyISAMdoes not overwrite existing files and returns an error instead. The default value isOFF(0).如果使用
DATA DIRECTORY或MyISAM选项创建INDEX DIRECTORY表,并且发现已有的.MYD或.MYI文件,MyISAM 总是返回错误。它不会覆盖指定目录中的文件。If aMyISAMtable is created with aDATA DIRECTORYorINDEX DIRECTORYoption and an existing.MYDor.MYIfile is found, MyISAM always returns an error. It does not overwrite a file in the specified directory.命令行格式Command-Line Format --key-buffer-size=#系统变量System Variable key_buffer_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 forMyISAMtables are buffered and are shared by all threads.key_buffer_sizeis 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 setkey_buffer_sizeto 0 dynamically. A setting of 0 drops the key cache, which is not permitted at runtime. Settingkey_buffer_sizeto 0 is permitted only at startup, in which case the key cache is not initialized. Changing thekey_buffer_sizesetting at runtime from a value of 0 to a permitted non-zero value initializes the key cache.key_buffer_size只能以 4096 字节的增量或倍数来增加或减少。以不符合增量的值增加或减少该设置会产生警告,并将该设置截断为符合要求的值。key_buffer_sizecan 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 forkey_buffer_sizeis 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 theMyISAMstorage 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 toMyISAM.为了在同时写入多行时获得更高的速度,请使用
LOCK TABLES。参见 第 10.2.5.1 节,“优化 INSERT 语句”。For even more speed when writing many rows at the same time, useLOCK 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 aSHOW STATUSstatement and examining theKey_read_requests,Key_reads,Key_write_requests, andKey_writesstatus variables. (See Section 15.7.7, “SHOW Statements”.) TheKey_reads/Key_read_requestsratio should normally be less than 0.01. TheKey_writes/Key_write_requestsratio 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 theDELAY_KEY_WRITEtable option.可以使用
key_buffer_size结合Key_blocks_unused状态变量以及可通过key_cache_block_size系统变量获得的缓冲区块大小来确定关键缓冲区的使用比例:The fraction of the key buffer in use can be determined usingkey_buffer_sizein conjunction with theKey_blocks_unusedstatus variable and the buffer block size, which is available from thekey_cache_block_sizesystem 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 multipleMyISAMkey caches. The size limit of 4GB applies to each cache individually, not as a group. See Section 10.10.2, “The MyISAM Key Cache”.命令行格式Command-Line Format --key-cache-age-threshold=#系统变量System Variable key_cache_age_threshold范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --key-cache-block-size=#系统变量System Variable key_cache_block_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --key-cache-division-limit=#系统变量System Variable key_cache_division_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
系统变量System Variable large_files_support范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean mysqld 是否已使用大文件支持选项进行编译。Whether mysqld was compiled with options for large file support.
命令行格式Command-Line Format --large-pages[={OFF|ON}]系统变量System Variable large_pages范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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-pagesoption). See Section 10.12.3.3, “Enabling Large Page Support”.系统变量System Variable large_page_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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()时,它会被存储在二进制日志中。设置该变量不会更新mysql_insert_id()C API 函数返回的值。The value to be returned fromLAST_INSERT_ID(). This is stored in the binary log when you useLAST_INSERT_ID()in a statement that updates a table. Setting this variable does not update the value returned by themysql_insert_id()C API function.命令行格式Command-Line Format --lc-messages=name系统变量System Variable lc_messages范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value en_US用于错误消息的区域设置。默认值为
en_US。服务器将该参数转换为语言名称,并将其与lc_messages_dir的值结合,以生成错误消息文件的位置。参见第 12.12 节,“设置错误消息语言”。The locale to use for error messages. The default isen_US. The server converts the argument to a language name and combines it with the value oflc_messages_dirto produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.命令行格式Command-Line Format --lc-messages-dir=dir_name系统变量System Variable lc_messages_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 oflc_messagesto produce the location for the error message file. See Section 12.12, “Setting the Error Message Language”.命令行格式Command-Line Format --lc-time-names=value--lc-time-names=value系统变量System Variable lc_time_names范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theDATE_FORMAT(),DAYNAME()andMONTHNAME()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”.系统变量System Variable licenselicense范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value GPL服务器拥有的许可证类型。The type of license the server has.
命令行格式Command-Line Format --local-infile[={OFF|ON}]系统变量System Variable local_infile范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF该变量控制服务器端
LOCAL功能,用于LOAD DATA语句。根据local_infile的设置,服务器会拒绝或允许客户端在客户端启用了LOCAL的情况下加载本地数据。This variable controls server-sideLOCALcapability forLOAD DATAstatements. Depending on thelocal_infilesetting, the server refuses or permits local data loading by clients that haveLOCALenabled 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 permitLOAD DATA LOCALstatements (regardless of how client programs and libraries are configured at build time or runtime), start mysqld withlocal_infiledisabled or enabled, respectively.local_infilecan also be set at runtime. For more information, see Section 8.1.6, “Security Considerations for LOAD DATA LOCAL”.命令行格式Command-Line Format --lock-wait-timeout=#系统变量System Variable lock_wait_timeout范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 asLOCK TABLES,FLUSH TABLES WITH READ LOCK, andHANDLERstatements.此超时不适用于对
mysql数据库中的系统表的隐式访问,例如由GRANT或REVOKE语句或表日志语句修改的授权表。超时适用于直接访问的系统表,例如使用SELECT或UPDATE。This timeout does not apply to implicit accesses to system tables in themysqldatabase, such as grant tables modified byGRANTorREVOKEstatements or table logging statements. The timeout does apply to system tables accessed directly, such as withSELECTorUPDATE.超时值分别适用于每次元数据锁尝试。一个给定的语句可能需要多个锁,因此在报告超时错误之前,该语句可能会阻塞的时间超过
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 thelock_wait_timeoutvalue before reporting a timeout error. When lock timeout occurs,ER_LOCK_WAIT_TIMEOUTis reported.lock_wait_timeout也定义了LOCK INSTANCE FOR BACKUP语句在放弃之前等待锁的时间。lock_wait_timeoutalso defines the amount of time that aLOCK INSTANCE FOR BACKUPstatement waits for a lock before giving up.locked_in_memorylocked_in_memory系统变量System Variable locked_in_memorylocked_in_memory范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF无论 mysqld 是否通过
--memlock锁定在内存中。Whether mysqld was locked in memory with--memlock.命令行格式Command-Line Format --log-error[=file_name]--log-error[=file_name]系统变量System Variable log_error范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 文件名File name 默认的错误日志目标。如果目标是控制台,则值为
stderr。否则,目标是一个文件,并且log_error的值为文件名。参见 第 7.4.2 节,“错误日志”。The default error log destination. If the destination is the console, the value isstderr. Otherwise, the destination is a file and thelog_errorvalue is the file name. See Section 7.4.2, “The Error Log”.log_error_serviceslog_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_VARHint 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 inlog_error_servicesis implicitly loaded if it is not already loaded. For more information, see Section 7.4.2.1, “Error Log Configuration”.命令行格式Command-Line Format --log-error-suppression-list=value系统变量System Variable log_error_suppression_list范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value empty stringempty stringlog_error_suppression_list系统变量适用于计划写入错误日志的事件,并指定在事件具有WARNING或INFORMATION优先级时应抑制哪些事件。例如,如果某种类型的警告被认为在错误日志中是不希望出现的“噪音”,因为它出现频繁但没有实际意义,则可以对其进行抑制。该变量影响由log_filter_internal错误日志过滤组件执行的过滤操作,该组件默认启用(参见 第 7.5.3 节,“错误日志组件”)。如果log_filter_internal被禁用,log_error_suppression_list将不起作用。Thelog_error_suppression_listsystem variable applies to events intended for the error log and specifies which events to suppress when they occur with a priority ofWARNINGorINFORMATION. 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 thelog_filter_internalerror log filter component, which is enabled by default (see Section 7.5.3, “Error Log Components”). Iflog_filter_internalis disabled,log_error_suppression_listhas no effect.log_error_suppression_list的值可以是空字符串,表示不抑制,或者是一个或多个用逗号分隔的值的列表,表示要抑制的错误代码。错误代码可以用符号形式或数字形式指定。数字代码可以带或不带MY-前缀。数字部分的前导零不重要。允许的代码格式示例:Thelog_error_suppression_listvalue 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 theMY-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 oflog_error_suppression_listcombines with that oflog_error_verbosity. For additional information, see Section 7.4.2.5, “Priority-Based Error Log Filtering (log_filter_internal)”.命令行格式Command-Line Format --log-error-verbosity=#系统变量System Variable log_error_verbosity范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2最小值Minimum Value 1最大值Maximum Value 3log_error_verbosity系统变量指定处理发送到错误日志的事件的详细程度。该变量会影响由log_filter_internal错误日志过滤组件执行的过滤操作,该组件默认启用(参见第 7.5.3 节,“错误日志组件”)。如果log_filter_internal被禁用,log_error_verbosity将不起作用。Thelog_error_verbositysystem variable specifies the verbosity for handling events intended for the error log. This variable affects filtering performed by thelog_filter_internalerror log filter component, which is enabled by default (see Section 7.5.3, “Error Log Components”). Iflog_filter_internalis disabled,log_error_verbosityhas no effect.记录到错误日志的事件优先级为
ERROR、WARNING或INFORMATION。log_error_verbosity根据允许写入日志的消息优先级来控制详细程度,如下表所示。Events intended for the error log have a priority ofERROR,WARNING, orINFORMATION.log_error_verbositycontrols 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 ERRORERROR2 ERROR,WARNINGERROR,WARNING3 ERROR,WARNING,INFORMATIONERROR,WARNING,INFORMATION还有一个优先级为
SYSTEM。关于非错误情况的系统消息会被记录到错误日志中,无论log_error_verbosity的值是多少。这些消息包括启动和关闭消息,以及一些重要的设置更改。There is also a priority ofSYSTEM. System messages about non-error situations are printed to the error log regardless of thelog_error_verbosityvalue. 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 oflog_error_verbositycombines with that oflog_error_suppression_list. For additional information, see Section 7.4.2.5, “Priority-Based Error Log Filtering (log_filter_internal)”.命令行格式Command-Line Format --log-output=name系统变量System Variable log_output范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 设置Set 默认值Default Value FILEFILE有效值Valid Values TABLETABLEFILEFILENONENONE用于一般查询日志和慢查询日志输出的目标。该值是一个或多个以逗号分隔的单词列表,可从
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 fromTABLE,FILE, andNONE.TABLEselects logging to thegeneral_logandslow_logtables in themysqlsystem schema.FILEselects logging to log files.NONEdisables logging. IfNONEis present in the value, it takes precedence over any other words that are present.TABLEandFILEcan 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 thegeneral_logandslow_query_logsystem variables. ForFILElogging, thegeneral_log_fileandslow_query_log_filesystem variables determine the log file locations. For more information, see Section 7.4.1, “Selecting General Query Log and Slow Query Log Output Destinations”.命令行格式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_VARHint 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.
命令行格式Command-Line Format --log-raw[={OFF|ON}]--log-raw[={OFF|ON}]系统变量System Variable log_raw范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFFlog_raw系统变量最初设置为--log-raw选项的值。有关更多信息,请参见该选项的描述。系统变量也可以在运行时设置,以更改密码掩码行为。Thelog_rawsystem variable is initially set to the value of the--log-rawoption. See the description of that option for more information. The system variable may also be set at runtime to change password masking behavior.命令行格式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_VARHint 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 includeALTER TABLE,ANALYZE TABLE,CHECK TABLE,CREATE INDEX,DROP INDEX,OPTIMIZE TABLE, andREPAIR TABLE.命令行格式Command-Line Format --log-slow-extra[={OFF|ON}]系统变量System Variable log_slow_extra范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF如果启用了慢查询日志且输出目标包括
FILE,服务器会向日志文件行写入附加字段,以提供有关慢查询语句的信息。请参见第 7.4.5 节,“慢查询日志”。TABLE输出不受影响。If the slow query log is enabled and the output destination includesFILE, the server writes additional fields to log file lines that provide information about slow statements. See Section 7.4.5, “The Slow Query Log”.TABLEoutput is unaffected.命令行格式Command-Line Format --log-timestamps=#系统变量System Variable log_timestamps范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value UTCUTC有效值Valid Values UTCUTCSYSTEMSYSTEM此变量控制写入错误日志的消息以及写入文件的一般查询日志和慢查询日志消息的时间戳时区。它不会影响写入表(
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 withCONVERT_TZ()or by setting the sessiontime_zonesystem variable.允许的
log_timestamps值为UTC(默认值)和SYSTEM(本地系统时区)。Permittedlog_timestampsvalues areUTC(the default) andSYSTEM(the local system time zone).时间戳使用 ISO 8601 / RFC 3339 格式记录:
,并附加尾部值YYYY-MM-DDThh:mm:ss.uuuuuuZ表示 Zulu 时间(UTC)或±hh:mm(UTC 偏移)。Timestamps are written using ISO 8601 / RFC 3339 format:plus a tail value ofYYYY-MM-DDThh:mm:ss.uuuuuuZsignifying 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_VARHint 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 节,“慢查询日志”。Iflog_queries_not_using_indexesis enabled, thelog_throttle_queries_not_using_indexesvariable 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”.命令行格式Command-Line Format --long-query-time=#系统变量System Variable long_query_time范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theSlow_queriesstatus 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 oflong_query_timeare 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 along_query_timesetting 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-timeto change the session value of the system variable to a higher value.命令行格式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_VARHint 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 to1, allINSERT,UPDATE,DELETE, andLOCK TABLE WRITEstatements wait until there is no pendingSELECTorLOCK TABLE READon 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 asMyISAM,MEMORY, andMERGE). 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”.
系统变量System Variable lower_case_file_system范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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.OFFmeans file names are case-sensitive,ONmeans 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.命令行格式Command-Line Format --lower-case-table-names[=#]系统变量System Variable lower_case_table_names范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 (seelower_case_file_system). On Linux and other Unix-like systems, the default is0. On Windows the default value is1. On macOS, the default value is2. On Linux (and other Unix-like systems), setting the value to2is not supported; the server forces the value to0instead.你应该在多线程系统中设置
lower_case_table_names为 0,如果你在数据目录位于大小写不敏感文件系统(例如 Windows 或 macOS)上的系统上运行 MySQL。这是一种不受支持的组合,可能在使用错误的INSERT INTO ... SELECT ... FROM字母大小写进行操作时导致挂起情况。tbl_nametbl_name使用MyISAM访问不同字母大小写的表名可能导致索引损坏。You should not setlower_case_table_namesto 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 anINSERT INTO ... SELECT ... FROMoperation with the wrongtbl_nametbl_namelettercase. WithMyISAM, 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=0on 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 alower_case_table_namessetting 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 configurelower_case_table_namesto the desired setting before initializing the server. In most cases, this requires configuringlower_case_table_namesin 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 thedebconf-set-selectionutility prior to installing MySQL using APT to enablelower_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"命令行格式Command-Line Format --mandatory-roles=value系统变量System Variable mandatory_roles范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 settingmandatory_rolesdoes not actually change any user accounts, and the granted roles are not visible in themysql.role_edgessystem 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 ofmandatory_rolesrequires theROLE_ADMINprivilege, in addition to theSYSTEM_VARIABLES_ADMINprivilege (or the deprecatedSUPERprivilege) 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 informat. The host part, if omitted, defaults touser_name@host_name%. For additional information, see Section 8.2.5, “Specifying Role Names”.mandatory_roles的值是一个字符串,因此如果用户名和主机名被引用,必须以允许在引用字符串中使用的方式编写。Themandatory_rolesvalue 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 ofmandatory_rolescannot be revoked withREVOKEor dropped withDROP ROLEorDROP USER.为了防止会话默认成为系统会话,具有
SYSTEM_USER权限的角色不能列在mandatory_roles系统变量的值中:To prevent sessions from being made system sessions by default, a role that has theSYSTEM_USERprivilege cannot be listed in the value of themandatory_rolessystem variable:如果在启动时给
mandatory_roles分配了具有SYSTEM_USER权限的角色,服务器会在错误日志中写入一条消息并退出。Ifmandatory_rolesis assigned a role at startup that has theSYSTEM_USERprivilege, the server writes a message to the error log and exits.如果在运行时给
mandatory_roles分配了具有SYSTEM_USER权限的角色,会发生错误,并且mandatory_roles的值保持不变。Ifmandatory_rolesis assigned a role at runtime that has theSYSTEM_USERprivilege, an error occurs and themandatory_rolesvalue remains unchanged.
强制角色,如显式授予的角色,在激活之前不会生效(参见 激活角色)。在登录时,如果启用了
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 theactivate_all_roles_on_loginsystem variable is enabled; otherwise, or for roles that are set as default roles otherwise. At runtime,SET ROLEactivates roles.在分配给
mandatory_roles时不存在的角色,但以后创建的角色,可能需要特殊处理才能被视为强制角色。有关详细信息,请参阅 定义强制角色。Roles that do not exist when assigned tomandatory_rolesbut 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 GRANTSdisplays mandatory roles according to the rules described in Section 15.7.7.22, “SHOW GRANTS Statement”.命令行格式Command-Line Format --max-allowed-packet=#系统变量System Variable max_allowed_packet范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 themysql_stmt_send_long_data()C API function. The default is 64MB.数据包消息缓冲区初始化为
net_buffer_length字节,但在需要时可以增长到max_allowed_packet字节。这个值默认较小,以捕获大的(可能不正确的)数据包。The packet message buffer is initialized tonet_buffer_lengthbytes, but can grow up tomax_allowed_packetbytes 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 largeBLOBcolumns or long strings. It should be as big as the largestBLOByou want to use. The protocol limit formax_allowed_packetis 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 themax_allowed_packetvariable, you should also change the buffer size on the client side if your client program permits it. The defaultmax_allowed_packetvalue 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 settingmax_allowed_packeton 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 globalmax_allowed_packetvalue. (The global value could be less than the session value if the global value is changed after the client connects.)命令行格式Command-Line Format --max-connect-errors=#系统变量System Variable max_connect_errors范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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次尝试内成功建立,则该主机的错误计数将清零。要解除对被阻止主机的阻止,请刷新主机缓存;参见 刷新主机缓存。Aftermax_connect_errorssuccessive 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 thanmax_connect_errorsattempts 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.命令行格式Command-Line Format --max-connections=#系统变量System Variable max_connections范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofopen_files_limit- 810, and the value actually set formax_connections.更多信息,请参见 第 7.1.12.1 节,“连接接口”。For more information, see Section 7.1.12.1, “Connection Interfaces”.
命令行格式Command-Line Format --max-delayed-threads=#已弃用Deprecated 是Yes 系统变量System Variable max_delayed_threads范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 20最小值Minimum Value 0最大值Maximum Value 16384这个系统变量已被弃用(因为不支持
DELAYED插入),并可能在将来的 MySQL 版本中被移除。This system variable is deprecated (becauseDELAYEDinserts 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”.
命令行格式Command-Line Format --max-digest-length=#系统变量System Variable max_digest_length范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 toLENGTH(STATEMENT_DIGEST_TEXT(. This means that, when the value ofstatement) ) + 64max_digest_lengthis 1024 (the default), the maximum length for a normalized SQL statement before truncation occurs is in effect 960 bytes.Warning将
max_digest_length设置为零会禁用摘要生成,这也会禁用需要摘要的服务器功能,例如 MySQL 企业防火墙。Settingmax_digest_lengthto zero disables digest production, which also disables server functionality that requires digests, such as MySQL Enterprise Firewall.降低
max_digest_length值可以减少内存使用,但如果语句仅在末尾不同,则更多语句的摘要值将无法区分。增加该值可以区分更长的语句,但会增加内存使用,尤其是对于涉及大量并发会话的工作负载(服务器为每个会话分配max_digest_length字节)。Decreasing themax_digest_lengthvalue 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 allocatesmax_digest_lengthbytes 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 theperformance_schema_max_digest_length. system variable as a limit on the maximum length of digests that it stores. Consequently, ifperformance_schema_max_digest_lengthis less thanmax_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”.
命令行格式Command-Line Format --max-error-count=#系统变量System Variable max_error_count范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 整数Integer 默认值Default Value 1024最小值Minimum Value 0最大值Maximum Value 65535SHOW ERRORS和SHOW WARNINGS语句用于存储显示的最大错误、警告和信息消息数量。这与诊断区中的条件区数量相同,因此也就是可被GET DIAGNOSTICS检查的条件数量。The maximum number of error, warning, and information messages to be stored for display by theSHOW ERRORSandSHOW WARNINGSstatements. This is the same as the number of condition areas in the diagnostics area, and thus the number of conditions that can be inspected byGET 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”.
命令行格式Command-Line Format --max-execution-time=#系统变量System Variable max_execution_time范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 4294967295单位Unit 毫秒milliseconds SELECT语句的执行超时时间,单位为毫秒。如果值为 0,则不启用超时。The execution timeout forSELECTstatements, in milliseconds. If the value is 0, timeouts are not enabled.max_execution_time的应用如下:max_execution_timeapplies as follows:全局
max_execution_time值为新连接的会话值提供默认值。会话值适用于会话内执行的SELECT操作,如果没有包含MAX_EXECUTION_TIME(优化器提示,或者N)N为 0 的情况。The globalmax_execution_timevalue provides the default for the session value for new connections. The session value applies toSELECTexecutions executed within the session that include noMAX_EXECUTION_TIME(optimizer hint or for whichN)Nis 0.max_execution_time适用于只读的SELECT语句。非只读语句是指调用会以副作用修改数据的存储函数的语句。max_execution_timeapplies to read-onlySELECTstatements. 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_timeis ignored forSELECTstatements in stored programs.
命令行格式Command-Line Format --max-heap-table-size=#系统变量System Variable max_heap_table_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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-createdMEMORYtables are permitted to grow. The value of the variable is used to calculateMEMORYtableMAX_ROWSvalues.设置此变量对任何现有的
MEMORY表没有影响,除非使用CREATE TABLE语句重新创建表,或使用ALTER TABLE或TRUNCATE TABLE修改表。服务器重启也会将现有MEMORY表的最大大小设置为全局max_heap_table_size值。Setting this variable has no effect on any existingMEMORYtable, unless the table is re-created with a statement such asCREATE TABLEor altered withALTER TABLEorTRUNCATE TABLE. A server restart also sets the maximum size of existingMEMORYtables to the globalmax_heap_table_sizevalue.该变量还与
tmp_table_size一起使用,以限制内部内存表的大小。请参阅 第 10.4.4 节,“MySQL 中的内部临时表使用”。This variable is also used in conjunction withtmp_table_sizeto 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_sizeis not replicated. See Section 19.5.1.21, “Replication and MEMORY Tables”, and Section 19.5.1.39, “Replication and Variables”, for more information.已弃用Deprecated 是Yes 系统变量System Variable max_insert_delayed_threads范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 formax_delayed_threads. Likemax_delayed_threads, it is deprecated (becauseDELAYEDinserts 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”.
命令行格式Command-Line Format --max-join-size=#系统变量System Variable max_join_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thanmax_join_sizemust 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 thanDEFAULTresets the value ofsql_big_selectsto0. If you set thesql_big_selectsvalue again, themax_join_sizevariable is ignored.命令行格式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_VARHint 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.
命令行格式Command-Line Format --max-points-in-geometry=#系统变量System Variable max_points_in_geometry范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 整数Integer 默认值Default Value 65536最小值Minimum Value 3最大值Maximum Value 1048576作为
ST_Buffer_Strategy()函数points_per_circle参数的最大值。The maximum value of thepoints_per_circleargument to theST_Buffer_Strategy()function.命令行格式Command-Line Format --max-prepared-stmt-count=#系统变量System Variable max_prepared_stmt_count范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --max-seeks-for-key=#系统变量System Variable max_seeks_for_key范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --max-sort-length=#系统变量System Variable max_sort_length范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 usePAD SPACEcollations. The server uses only the firstmax_sort_lengthbytes of any such value and ignores the rest. Consequently, such values that differ only after the firstmax_sort_lengthbytes compare as equal forGROUP BY,ORDER BY, andDISTINCToperations. (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 ofmax_sort_lengthmay require increasing the value ofsort_buffer_sizeas well. For details, see Section 10.2.1.16, “ORDER BY Optimization”命令行格式Command-Line Format --max-sp-recursion-depth[=#]系统变量System Variable max_sp_recursion_depth范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofmax_sp_recursion_depth, it may be necessary to increase thread stack size by increasing the value ofthread_stackat server startup.命令行格式Command-Line Format --max-user-connections=#系统变量System Variable max_user_connections范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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:
如果用户帐户有非零的
MAX_USER_CONNECTIONS资源限制,则会话max_user_connections值将设置为该限制。If the user account has a nonzeroMAX_USER_CONNECTIONSresource limit, the sessionmax_user_connectionsvalue is set to that limit.否则,会话
max_user_connections值将设置为全局值。Otherwise, the sessionmax_user_connectionsvalue is set to the global value.
帐户资源限制是使用
CREATE USER或ALTER USER语句指定的。参见 第 8.2.21 节,“设置帐户资源限制”。Account resource limits are specified using theCREATE USERorALTER USERstatement. See Section 8.2.21, “Setting Account Resource Limits”.命令行格式Command-Line Format --max-write-lock-count=#系统变量System Variable max_write_lock_count范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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, ifmax_write_lock_countis 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 becausemax_write_lock_countby default has a very large value.命令行格式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_VARHint Applies否No 类型Type 文件名File name mecab_rc_file选项用于设置 MeCab 全文解析器时使用。Themecab_rc_fileoption is used when setting up the MeCab full-text parser.mecab_rc_file选项定义了mecabrc配置文件的路径,该文件是 MeCab 的配置文件。此选项为只读,仅能在启动时设置。初始化 MeCab 时需要mecabrc配置文件。Themecab_rc_fileoption defines the path to themecabrcconfiguration file, which is the configuration file for MeCab. The option is read-only and can only be set at startup. Themecabrcconfiguration 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 MeCabmecabrcconfiguration file, refer to the MeCab Documentation on the Google Developers site.命令行格式Command-Line Format --min-examined-row-limit=#系统变量System Variable min_examined_row_limit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --myisam-data-pointer-size=#系统变量System Variable myisam_data_pointer_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 byCREATE TABLEforMyISAMtables when noMAX_ROWSoption 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”.命令行格式Command-Line Format --myisam-max-sort-file-size=#系统变量System Variable myisam_max_sort_file_size范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 aMyISAMindex (duringREPAIR TABLE,ALTER TABLE, orLOAD 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索引文件超过此大小并且磁盘空间充足,增加该值可能会提升性能。所需空间必须在包含原索引文件目录的文件系统中可用。IfMyISAMindex 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.命令行格式Command-Line Format --myisam-mmap-size=#系统变量System Variable myisam_mmap_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 compressedMyISAMfiles. If many compressedMyISAMtables are used, the value can be decreased to reduce the likelihood of memory-swapping problems.命令行格式Command-Line Format --myisam-recover-options[=list]系统变量System Variable myisam_recover_options范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value OFFOFF有效值Valid Values OFFOFFDEFAULTDEFAULTBACKUPBACKUPFORCEFORCEQUICKQUICK设置
MyISAM存储引擎的恢复模式。变量值可以是OFF、DEFAULT、BACKUP、FORCE或QUICK的任意组合。如果指定多个值,请用逗号分隔。在服务器启动时指定变量而不赋值,相当于指定DEFAULT;明确指定值为""会禁用恢复(与值为OFF相同)。如果启用恢复,每次 mysqld 打开MyISAM表时,会检查该表是否标记为崩溃或未正确关闭。(最后一个选项仅在禁用外部锁时有效。)如果存在这种情况,mysqld 会对表进行检查。如果表损坏,mysqld 会尝试修复它。Set theMyISAMstorage engine recovery mode. The variable value is any combination of the values ofOFF,DEFAULT,BACKUP,FORCE, orQUICK. If you specify multiple values, separate them by commas. Specifying the variable with no value at server startup is the same as specifyingDEFAULT, and specifying with an explicit value of""disables recovery (same as a value ofOFF). If recovery is enabled, each time mysqld opens aMyISAMtable, 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。If the data file was changed during recovery, save a backup of thetbl_name-datetime.BAKfile astbl_name.MYD.tbl_name-datetime.BAKFORCEFORCE即使我们会从 .MYD文件中丢失多于一行,也要运行恢复。Run recovery even if we would lose more than one row from the.MYDfile.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 optionsBACKUP,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”.
命令行格式Command-Line Format --myisam-sort-buffer-size=#系统变量System Variable myisam_sort_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 sortingMyISAMindexes during aREPAIR TABLEor when creating indexes withCREATE INDEXorALTER TABLE.命令行格式Command-Line Format --myisam-stats-method=name系统变量System Variable myisam_stats_method范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value nulls_unequal有效值Valid Values nulls_unequalnulls_equalnulls_equalnulls_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 treatsNULLvalues when collecting statistics about the distribution of index values forMyISAMtables. This variable has three possible values,nulls_equal,nulls_unequal, andnulls_ignored. Fornulls_equal, allNULLindex values are considered equal and form a single value group that has a size equal to the number ofNULLvalues. Fornulls_unequal,NULLvalues are considered unequal, and eachNULLforms a distinct value group of size 1. Fornulls_ignored,NULLvalues 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”.
命令行格式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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF用于读取和写入
MyISAM表时使用内存映射。Use memory mapping for reading and writingMyISAMtables.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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF此变量控制内置的
mysql_native_password身份验证插件(已弃用)是否支持代理用户。除非启用了check_proxy_users系统变量和mysql_native_password插件,否则此变量不会生效。有关用户代理的信息,请参见 第 8.2.19 节,“代理用户”。This variable controls whether themysql_native_passwordbuilt-in authentication plugin (deprecated) supports proxy users. It has no effect unless thecheck_proxy_userssystem variable and themysql_native_passwordplugin are enabled. For information about user proxying, see Section 8.2.19, “Proxy Users”.命令行格式Command-Line Format --named-pipe[={OFF|ON}]--named-pipe[={OFF|ON}]系统变量System Variable named_pipenamed_pipe范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 特定平台Platform Specific 窗口Windows 类型Type 布尔Boolean 默认值Default Value OFFOFF(仅限 Windows。)指示服务器是否支持通过命名管道进行连接。(Windows only.) Indicates whether the server supports connections over named pipes.
命令行格式Command-Line Format --named-pipe-full-access-group=value系统变量System Variable named_pipe_full_access_group范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 特定平台Platform Specific 窗口Windows 类型Type 字符串String 默认值Default Value empty stringempty string有效值Valid Values empty stringempty stringvalid 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 thenamed_pipesystem 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.命令行格式Command-Line Format --net-buffer-length=#系统变量System Variable net_buffer_length范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 bynet_buffer_lengthbut are dynamically enlarged up tomax_allowed_packetbytes as needed. The result buffer shrinks tonet_buffer_lengthafter 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 whichnet_buffer_lengthcan be set is 1MB.此变量的会话值为只读。The session value of this variable is read only.
命令行格式Command-Line Format --net-read-timeout=#系统变量System Variable net_read_timeout范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_timeoutis the timeout value controlling when to abort. When the server is writing to the client,net_write_timeoutis the timeout value controlling when to abort. See alsoreplica_net_timeout.命令行格式Command-Line Format --net-retry-count=#系统变量System Variable net_retry_count范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --net-write-timeout=#系统变量System Variable net_write_timeout范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 alsonet_read_timeout.命令行格式Command-Line Format --ngram-token-size=#系统变量System Variable ngram_token_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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. Thengram_token_sizeoption 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”.
命令行格式Command-Line Format --offline-mode[={OFF|ON}]系统变量System Variable offline_mode范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 anER_SERVER_OFFLINE_MODEerror.要将服务器设置为离线模式,请将系统变量
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 theoffline_modesystem variable fromOFFtoON. To resume normal operations, changeoffline_modefromONtoOFF. To control offline mode, an administrator account must have theSYSTEM_VARIABLES_ADMINprivilege and theCONNECTION_ADMINprivilege (or the deprecatedSUPERprivilege, which covers both these privileges).CONNECTION_ADMINis required, to prevent accidental lockout.离线模式具有以下特点:Offline mode has these characteristics:
没有
CONNECTION_ADMIN权限(或已废弃的SUPER权限)的已连接客户端用户将在下一次请求时被断开连接,并显示相应的错误。断开连接包括终止正在运行的语句和释放锁。此类客户端也无法发起新的连接,并会收到相应的错误。Connected client users who do not have theCONNECTION_ADMINprivilege (or the deprecatedSUPERprivilege) 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 theCONNECTION_ADMINorSUPERprivilege 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_USERprivilege, connected client users who have theSYSTEM_USERprivilege are also not disconnected. However, these users cannot initiate new connections to the server while it is in offline mode, unless they have theCONNECTION_ADMIN或者SUPERprivilege as well. It is only their existing connection that cannot be terminated, because theSYSTEM_USERprivilege is required to kill a session or statement that is executing with theSYSTEM_USER特权。If the user that puts a server in offline mode does not have theSYSTEM_USERprivilege, connected client users who have theSYSTEM_USERprivilege are also not disconnected. However, these users cannot initiate new connections to the server while it is in offline mode, unless they have theCONNECTION_ADMINorSUPERprivilege as well. It is only their existing connection that cannot be terminated, because theSYSTEM_USERprivilege is required to kill a session or statement that is executing with theSYSTEM_USERprivilege.允许复制线程继续向服务器应用数据。Replication threads are permitted to keep applying data to the server.
命令行格式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_VARHint 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 anALTER TABLEoperation. 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 ofALTER 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 PARTITIONwithold_alter_table=ONrebuilds the partitioned table and attempts to move data from the dropped partition to another partition with a compatiblePARTITION ... VALUESdefinition. Data that cannot be moved to another partition is deleted. In earlier releases,ALTER TABLE ... DROP PARTITIONwithold_alter_table=ONdeletes data stored in the partition and drops the partition.命令行格式Command-Line Format --open-files-limit=#系统变量System Variable open_files_limit范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 withsetrlimit(), using the value requested at by setting this variable directly or by using the--open-files-limitoption to mysqld_safe. If mysqld produces the errorToo many open files, try increasing theopen_files_limitvalue. 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 ofopen_files_limitindicates 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 effectiveopen_files_limitvalue is based on the value specified at system startup (if any) and the values ofmax_connectionsandtable_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 usingsystemd, the value cannot be set greater thanLimitNOFILE(this isDefaultLimitNOFILE, ifLimitNOFILEis not set); otherwise, on Linux, the value ofopen_files_limitcannot exceed ulimit -n.命令行格式Command-Line Format --optimizer-prune-level=#系统变量System Variable optimizer_prune_level范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --optimizer-search-depth=#系统变量System Variable optimizer_search_depth范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --optimizer-switch=value系统变量System Variable optimizer_switch范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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,用于指示相应的优化器行为是启用还是禁用。该变量具有全局值和会话值,并且可以在运行时更改。全局默认值可以在服务器启动时设置。Theoptimizer_switchsystem variable enables control over optimizer behavior. The value of this variable is a set of flags, each of which has a value ofonoroffto 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”.
命令行格式Command-Line Format --optimizer-trace=value系统变量System Variable optimizer_trace范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 此变量用于控制优化器跟踪。详情请参见 第 10.15 节,“优化器跟踪”。This variable controls optimizer tracing. For details, see Section 10.15, “Tracing the Optimizer”.
命令行格式Command-Line Format --optimizer-trace-features=value系统变量System Variable optimizer_trace_features范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 此变量用于启用或禁用选定的优化器跟踪功能。有关详细信息,请参见 第 10.15 节,“跟踪优化器”。This variable enables or disables selected optimizer tracing features. For details, see Section 10.15, “Tracing the Optimizer”.
命令行格式Command-Line Format --optimizer-trace-limit=#系统变量System Variable optimizer_trace_limit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --optimizer-trace-max-mem-size=#系统变量System Variable optimizer_trace_max_mem_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --optimizer-trace-offset=#系统变量System Variable optimizer_trace_offset范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_xxxPerformance 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.
命令行格式Command-Line Format --parser-max-mem-size=#系统变量System Variable parser_max_mem_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --partial-revokes[={OFF|ON}]系统变量System Variable partial_revokes范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_revokesenables privileges for specific schemas to be revoked while leaving the privileges in place for other schemas. For example, a user who has the globalUPDATEprivilege can be restricted from exercising this privilege on themysqlsystem schema. (Or, stated another way, the user is enabled to exercise theUPDATEprivilege on all schemas except themysqlschema.) In this sense, the user's globalUPDATEprivilege is partially revoked.一旦启用,
partial_revokes如果任何账户存在权限限制,则无法禁用。如果存在这样的账户,禁用partial_revokes将失败:Once enabled,partial_revokescannot be disabled if any account has privilege restrictions. If any such account exists, disablingpartial_revokesfails:在启动时尝试禁用
partial_revokes时,服务器会记录一条错误消息并启用partial_revokes。For attempts to disablepartial_revokesat startup, the server logs an error message and enablespartial_revokes.尝试在运行时禁用
partial_revokes时,会发生错误,并且partial_revokes的值保持不变。For attempts to disablepartial_revokesat runtime, an error occurs and thepartial_revokesvalue remains unchanged.
要在这种情况下禁用
partial_revokes,首先需要修改每个拥有部分撤销权限的账户,要么重新授予权限,要么删除该账户。To disablepartial_revokesin 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, enablingpartial_revokescauses 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 wherepartial_revokesmay 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”.
命令行格式Command-Line Format --password-history=#系统变量System Variable password_history范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thePASSWORD HISTORY DEFAULToption.可以使用
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 thePASSWORD HISTORYoption of theCREATE USERandALTER USERstatements. See Section 8.2.15, “Password Management”.命令行格式Command-Line Format --password-require-current[={OFF|ON}]系统变量System Variable password_require_current范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thePASSWORD REQUIRE CURRENT DEFAULToption.可以使用
PASSWORD REQUIRE和ALTER USER语句中的CREATE USER选项,为单个账户按需覆盖全局必须验证策略。参见 第 8.2.15 节,“密码管理”。The global verification-required policy can be overridden as desired for individual accounts using thePASSWORD REQUIREoption of theCREATE USERandALTER USERstatements. See Section 8.2.15, “Password Management”.命令行格式Command-Line Format --password-reuse-interval=#系统变量System Variable password_reuse_interval范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thePASSWORD REUSE INTERVAL DEFAULToption.全局的基于时间间隔的密码重用策略可以根据需要针对单个账户进行覆盖,使用
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 thePASSWORD REUSE INTERVALoption of theCREATE USERandALTER USERstatements. See Section 8.2.15, “Password Management”.命令行格式Command-Line Format --persisted-globals-load[={OFF|ON}]系统变量System Variable persisted_globals_load范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 themysqld-auto.cnffile 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”). Disablingpersisted_globals_loadcauses the server startup sequence to skipmysqld-auto.cnf.要修改
mysqld-auto.cnf的内容,请使用SET PERSIST、SET PERSIST_ONLY和RESET PERSIST语句。请参阅 第 7.1.9.3 节,“持久化系统变量”。To modify the contents ofmysqld-auto.cnf, use theSET PERSIST,SET PERSIST_ONLY, andRESET PERSISTstatements. 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_VARHint Applies否No 类型Type 字符串String 默认值Default Value empty stringempty stringSET PERSIST和SET PERSIST_ONLY允许将系统变量持久化到数据目录中的mysqld-auto.cnf选项文件中(参见 第 15.7.6.1 节,“SET 变量赋值语法”)。持久化系统变量可以在运行时进行配置更改,从而影响后续服务器重启,这对于无需直接访问 MySQL 服务器主机选项文件的远程管理非常方便。然而,一些系统变量是不可持久化的,或者只能在某些限制条件下持久化。SET PERSISTandSET PERSIST_ONLYenable system variables to be persisted to themysqld-auto.cnfoption 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 检查,因此任何用户都无法持久化受持久化限制的系统变量。Thepersist_only_admin_x509_subjectsystem 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 节,“不可持久化和受限制持久化系统变量”。Ifpersist_only_admin_x509_subjectis nonempty, users who connect to the server using an encrypted connection and supply an SSL certificate with the designated Subject value then can useSET PERSIST_ONLYto persist persist-restricted system variables. For information about persist-restricted system variables and instructions for configuring MySQL to enablepersist_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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONONpersist_sensitive_variables_in_plaintext控制服务器是否允许以未加密的格式存储敏感系统变量的值,如果在使用SET PERSIST设置系统变量的值时,keyring 组件支持不可用。它还控制如果加密值无法解密,服务器是否能够启动。请注意,keyring 插件不支持对敏感系统变量的安全存储;必须在 MySQL 服务器实例上启用 keyring 组件(参见 第 8.4.4 节,“MySQL Keyring”)以支持安全存储。persist_sensitive_variables_in_plaintextcontrols 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 whenSET PERSISTis 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. TheONsetting 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. TheOFFsetting also means the server does not start if encrypted system variable values cannot be decrypted.更多信息,请参见 持久化敏感系统变量。For more information, see Persisting Sensitive System Variables.
命令行格式Command-Line Format --pid-file=file_name--pid-file=file_name系统变量System Variable pid_file范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 文件名File name 服务器写入其进程 ID 的文件的路径名。除非提供了绝对路径名来指定其他目录,否则服务器会在数据目录中创建该文件。如果您指定此变量,则必须指定一个值。如果您未指定此变量,MySQL 将使用默认值
,其中host_name.pidhost_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, wherehost_name.pidhost_nameis 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”.
命令行格式Command-Line Format --plugin-dir=dir_name--plugin-dir=dir_name系统变量System Variable plugin_dir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 usingSELECT ... INTO DUMPFILE. This can be prevented by makingplugin_dirread only to the server or by settingsecure_file_privto a directory whereSELECTwrites can be made safely.命令行格式Command-Line Format --port=port_num--port=port_num系统变量System Variable portport范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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--portoption.命令行格式Command-Line Format --preload-buffer-size=#系统变量System Variable preload_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式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_VARHint 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 theIDENTIFIED WITHclause of output fromSHOW CREATE USERmay contain unprintable characters that have adverse effects on terminal displays and in other environments. Enablingprint_identified_with_as_hexcausesSHOW CREATE USERto 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.如果设置为 0 或
OFF(默认值),语句分析将被禁用。如果设置为 1 或ON,语句分析将启用,并且SHOW PROFILE和SHOW PROFILES语句可以访问分析信息。参见 第 15.7.7.33 节,“SHOW PROFILES 语句”。If set to 0 orOFF(the default), statement profiling is disabled. If set to 1 orON, statement profiling is enabled and theSHOW PROFILEandSHOW PROFILESstatements 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,要为其维护分析信息的语句数量。默认值为 15。最大值为 100。将值设置为 0 将有效地禁用分析。参见第 15.7.7.33 节,“SHOW PROFILES 语句”。The number of statements for which to maintain profiling information ifprofilingis 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_VARHint Applies否No 类型Type 设置Set 默认值Default Value zlib,zstd,uncompressed有效值Valid Values zlibzstduncompresseduncompressed服务器允许用于传入连接的压缩算法。这包括客户端程序的连接以及参与源/副本复制或组复制的服务器的连接。压缩不适用于
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 forFEDERATEDtables.protocol_compression_algorithms不控制 X 协议的连接压缩。有关其工作方式的信息,请参阅 第 22.5.5 节,“X 插件的连接压缩”。protocol_compression_algorithmsdoes 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 thezlibcompression algorithm.zstd:允许使用zstd压缩算法的连接。zstd: Permit connections that use thezstdcompression algorithm.uncompressed:允许未压缩的连接。如果该算法名称未包含在protocol_compression_algorithms的值中,服务器将不允许未压缩连接。它只允许使用值中指定的其他算法的压缩连接,并且不会回退到未压缩连接。uncompressed: Permit uncompressed connections. If this algorithm name is not included in theprotocol_compression_algorithmsvalue, 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 ofzlib,zstd,uncompressedindicates that the server permits all compression algorithms.更多信息,请参阅 第 6.2.8 节,“连接压缩控制”。For more information, see Section 6.2.8, “Connection Compression Control”.
系统变量System Variable protocol_version范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 10最小值Minimum Value 0最大值Maximum Value 4294967295MySQL 服务器使用的客户端/服务器协议版本。The version of the client/server protocol used by the MySQL server.
系统变量System Variable proxy_user范围Scope 会议Session 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 isNULL. See Section 8.2.19, “Proxy Users”.pseudo_replica_modepseudo_replica_mode系统变量System Variable pseudo_replica_modepseudo_replica_mode范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean pseudo_replica_mode供服务器内部使用。它有助于正确处理那些比当前处理它们的服务器版本更新或更旧的服务器上发起的事务。mysqlbinlog 在执行任何 SQL 语句之前,将pseudo_replica_mode的值设置为 true。pseudo_replica_modeis 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 ofpseudo_replica_modeto true before executing any SQL statements.设置
pseudo_replica_mode的会话值是一项受限操作。会话用户必须拥有REPLICATION_APPLIER权限(参见 第 19.3.3 节,“复制权限检查”),或拥有足够权限以设置受限会话变量(参见 第 7.1.9.1 节,“系统变量权限”)。但是,请注意,该变量并非用于用户设置;它由复制基础设施自动设置。Setting the session value ofpseudo_replica_modeis a restricted operation. The session user must have either theREPLICATION_APPLIERprivilege (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_modehas 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 issuesXA START):如果为真,并且处理会话已经执行了内部使用的
BINLOG语句,当事务的第一部分直到XA PREPARE完成时,XA 事务会自动从会话中分离,因此任何具有XA_RECOVER_ADMIN权限的会话都可以提交或回滚它们。If true, and the handling session has executed an internal-useBINLOGstatement, XA transactions are automatically detached from the session as soon as the first part of the transaction up toXA PREPAREfinishes, so they can be committed or rolled back by any session that has theXA_RECOVER_ADMINprivilege.如果为假,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_modehas the following effects on theoriginal_commit_timestampreplication delay timestamp and theoriginal_server_versionsystem variable:如果为真,未明确设置
original_commit_timestamp或original_server_version的事务将被视为源自另一个未知服务器,因此时间戳和系统变量都分配值 0,表示未知。If true, transactions that do not explicitly setoriginal_commit_timestampororiginal_server_versionare 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 setoriginal_commit_timestampororiginal_server_versionare 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_modehas 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 withER_UNSUPPORTED_SQL_MODE.
已弃用Deprecated 是Yes 系统变量System Variable pseudo_slave_mode范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 已弃用的
pseudo_replica_mode的别名。Deprecated alias forpseudo_replica_mode.系统变量System Variable pseudo_thread_id范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thepseudo_thread_idsystem variable changes the value returned by theCONNECTION_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”.
命令行格式Command-Line Format --query-alloc-block-size=#系统变量System Variable query_alloc_block_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --query-prealloc-size=#已弃用Deprecated 是Yes 系统变量System Variable query_prealloc_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 1024query_prealloc_size已不推荐使用,设置它不会产生效果;您应该预期它将在 MySQL 的未来版本中被移除。query_prealloc_sizeis deprecated, and setting it has no effect; you should expect its removal in a future release of MySQL.系统变量System Variable rand_seed1范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value N/AN/A最小值Minimum Value 0最大值Maximum Value 4294967295rand_seed1和rand_seed2变量仅作为会话变量存在,可以设置但不能读取。变量本身——而不是它们的值——会显示在SHOW VARIABLES的输出中。Therand_seed1andrand_seed2variables exist as session variables only, and can be set but not read. The variables—but not their values—are shown in the output ofSHOW VARIABLES.这些变量的目的是支持
RAND()函数的复制。对于调用RAND()的语句,源端会将两个值传递给副本,这些值用于为随机数生成器设置种子。副本使用这些值来设置会话变量rand_seed1和rand_seed2,从而使副本上的RAND()生成的值与源端相同。The purpose of these variables is to support replication of theRAND()function. For statements that invokeRAND(), 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 variablesrand_seed1andrand_seed2so thatRAND()on the replica generates the same value as on the source.参见
rand_seed1的描述。See the description forrand_seed1.命令行格式Command-Line Format --range-alloc-block-size=#系统变量System Variable range_alloc_block_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
命令行格式Command-Line Format --range-optimizer-max-mem-size=#系统变量System Variable range_optimizer_max_mem_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
系统变量System Variable rbr_exec_mode范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value STRICTSTRICT有效值Valid Values STRICTSTRICTIDEMPOTENTIDEMPOTENT供 mysqlbinlog 内部使用。此变量用于在服务器之间切换
IDEMPOTENT模式和STRICT模式。IDEMPOTENT模式会在由 mysqlbinlog 生成的BINLOG语句中抑制重复键和未找到键的错误。当在导致与现有数据冲突的服务器上重放基于行的二进制日志时,此模式非常有用。当你通过指定--idempotent选项时,mysqlbinlog 会设置此模式,并将以下内容写入输出:For internal use by mysqlbinlog. This variable switches the server betweenIDEMPOTENTmode andSTRICTmode.IDEMPOTENTmode causes suppression of duplicate-key and no-key-found errors inBINLOGstatements 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--idempotentoption by writing the following to the output:SET SESSION RBR_EXEC_MODE=IDEMPOTENT;
命令行格式Command-Line Format --read-buffer-size=#系统变量System Variable read_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 aMyISAMtable 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 ofInnoDB:在对
ORDER BY排序行时,用于将索引缓存到临时文件(而不是临时表)中。For caching the indexes in a temporary file (not a temporary table), when sorting rows forORDER BY.用于向分区进行批量插入。For bulk insert into partitions.
用于缓存嵌套查询的结果。For caching results of nested queries.
read_buffer_size还在另一种特定于存储引擎的方式中使用:用于确定MEMORY表的内存块大小。read_buffer_sizeis also used in one other storage engine-specific way: to determine the memory block size forMEMORYtables.select_into_buffer_size用于SELECT INTO DUMPFILE和SELECT INTO OUTFILE语句的 I/O 缓存缓冲区。(read_buffer_size用于其他所有情况下的 I/O 缓存缓冲区大小。)select_into_buffer_sizeis used for the I/O cache buffer forSELECT INTO DUMPFILEandSELECT INTO OUTFILEstatements. (read_buffer_sizeis 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”.
命令行格式Command-Line Format --read-only[={OFF|ON}]--read-only[={OFF|ON}]系统变量System Variable read_only范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF如果
read_only系统变量启用,服务器不允许客户端进行更新,除非用户拥有CONNECTION_ADMIN权限(或已弃用的SUPER权限)。此变量默认禁用。If theread_onlysystem variable is enabled, the server permits no client updates except from users who have theCONNECTION_ADMINprivilege (or the deprecatedSUPERprivilege). This variable is disabled by default.服务器还支持一个
super_read_only系统变量(默认禁用),其具有以下效果:The server also supports asuper_read_onlysystem variable (disabled by default), which has these effects:如果启用了
super_read_only,服务器将禁止客户端更新,即使是拥有CONNECTION_ADMIN或SUPER权限的用户也不例外。Ifsuper_read_onlyis enabled, the server prohibits client updates, even from users who have theCONNECTION_ADMINorSUPERprivilege.将
super_read_only设置为ON会隐式地强制read_only设置为ON。Settingsuper_read_onlytoONimplicitly forcesread_onlytoON.将
read_only设置为OFF会隐式地强制super_read_only也为OFF。Settingread_onlytoOFFimplicitly forcessuper_read_onlytoOFF.
当
read_only启用且super_read_only启用时,服务器仍然允许以下操作:Whenread_onlyis enabled and whensuper_read_onlyis 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 enableread_onlyon 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 tablemysql.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 ofANALYZE TABLEorOPTIMIZE TABLEstatements. 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 ofFLUSH STATUSstatements, which are always written to the binary log.对
TEMPORARY表的操作。Operations onTEMPORARYtables.向日志表(
mysql.general_log和mysql.slow_log)插入数据;参见第 7.4.1 节,“选择通用查询日志和慢查询日志的输出目的地”。Inserts into the log tables (mysql.general_logandmysql.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 asUPDATEorTRUNCATE TABLEoperations.
对复制源服务器上的
read_only的更改不会复制到副本服务器。副本上的值可以独立于源服务器的设置进行设置。Changes toread_onlyon 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 enableread_only(including implicit attempts resulting from enablingsuper_read_only):如果您有任何显式锁(通过
LOCK TABLES获取)或有待处理的事务,则尝试会失败并发生错误。The attempt fails and an error occurs if you have any explicit locks (acquired withLOCK TABLES) or have a pending transaction.当其他客户端有正在执行的语句、活动的
LOCK TABLES WRITE或正在进行的提交时,尝试会被阻塞,直到锁被释放且语句和事务结束。在尝试启用read_only时挂起时,其他客户端对表锁或开始事务的请求也会被阻塞,直到read_only被设置。The attempt blocks while other clients have any ongoing statement, activeLOCK TABLES WRITE, or ongoing commit, until the locks are released and the statements and transactions end. While the attempt to enableread_onlyis pending, requests by other clients for table locks or to begin transactions also block untilread_onlyhas 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_onlycan be enabled while you hold a global read lock (acquired withFLUSH TABLES WITH READ LOCK) because that does not involve table locks.
命令行格式Command-Line Format --read-rnd-buffer-size=#系统变量System Variable read_rnd_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 整数Integer 默认值Default Value 262144最小值Minimum Value 1最大值Maximum Value 2147483647单位Unit 字节bytes 此变量用于从
MyISAM表读取,并且对于任何存储引擎,用于多范围读取优化。This variable is used for reads fromMyISAMtables, and, for any storage engine, for Multi-Range Read optimization.在对
MyISAM表执行按键排序操作后按顺序读取行时,这些行会通过此缓冲区读取,以避免磁盘查找。请参见 第 10.2.1.16 节,“ORDER BY 优化”。将该变量设置为较大值可以大幅提高ORDER BY的性能。然而,这是为每个客户端分配的缓冲区,因此不应将全局变量设置为较大值。相反,应仅在那些需要运行大查询的客户端中更改会话变量。When reading rows from aMyISAMtable 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 improveORDER BYperformance 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”.
命令行格式Command-Line Format --regexp-stack-limit=#系统变量System Variable regexp_stack_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 byREGEXP_LIKE()and similar functions (see Section 14.8.2, “Regular Expressions”).命令行格式Command-Line Format --regexp-time-limit=#系统变量System Variable regexp_time_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 byREGEXP_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.系统变量System Variable require_row_format范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 toONrequires no privileges. Setting the session value of this system variable toOFFis 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”.命令行格式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_VARHint 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 anER_SECURE_TRANSPORT_REQUIREDerror.此功能补充了每个账户的 SSL 要求,这些要求具有优先权。例如,如果账户被定义为
REQUIRE SSL,启用require_secure_transport并不能使该账户通过 Unix 套接字文件连接成为可能。This capability supplements per-account SSL requirements, which take precedence. For example, if an account is defined withREQUIRE SSL, enablingrequire_secure_transportdoes 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 theshared_memorysystem variable disabled. Under these conditions, attempts to enablerequire_secure_transportat startup cause the server to write a message to the error log and exit. Attempts to enable the variable at runtime fail with anER_NO_SECURE_TRANSPORTS_CONFIGUREDerror.所有复制组成员该变量的值应相同;否则,某些成员可能无法加入。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_VARHint 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, whenON(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, useSET @@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 aCREATE TABLEorALTER TABLEstatement is deprecated, and you should expect support for it to be removed in a future version of MySQL. Whenrestrict_fk_on_non_standard_keyisON, attempts to do so are rejected withER_FK_NO_INDEX_PARENT; when it isOFF, this usage is permitted but still raisesER_WARN_DEPRECATED_NON_STANDARD_KEYas a warning.restrict_fk_on_non_standard_key已被弃用,并可能在未来的 MySQL 版本中移除。设置该选项会触发弃用警告。restrict_fk_on_non_standard_keyis 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 becauserestrict_fk_on_non_standard_keyisOFF, the statement succeeds on the replica regardless of any setting on the replica for this variable.系统变量System Variable resultset_metadata范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value FULLFULL有效值Valid Values FULLFULLNONENONE对于元数据传输可选的连接,客户端设置
resultset_metadata系统变量来控制服务器是否返回结果集元数据。允许的值为FULL(返回所有元数据;默认值)和NONE(不返回元数据)。For connections for which metadata transfer is optional, the client sets theresultset_metadatasystem variable to control whether the server returns result set metadata. Permitted values areFULL(return all metadata; this is the default) andNONE(return no metadata).对于非元数据可选的连接,将
resultset_metadata设置为NONE会产生错误。For connections that are not metadata-optional, settingresultset_metadatatoNONEproduces 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.
命令行格式Command-Line Format --schema-definition-cache=#系统变量System Variable schema_definition_cache范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 byschema_definition_cache.设置
0表示模式定义对象仅在使用时保存在字典对象缓存中。A setting of0means 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”.
命令行格式Command-Line Format --secure-file-priv=dir_name系统变量System Variable secure_file_priv范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value platform specificplatform specific有效值Valid Values empty stringempty stringdirnameNULL此变量用于限制数据导入和导出操作的影响,例如
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 theLOAD DATAandSELECT ... INTO OUTFILEstatements and theLOAD_FILE()function. These operations are permitted only to users who have theFILEprivilege.secure_file_priv可以按如下方式设置:secure_file_privmay 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 toNULL, the server disables import and export operations.
默认值是特定于平台的,并依赖于
INSTALL_LAYOUTCMake 选项的值,如下表所示。如果您从源代码构建并希望明确指定默认的secure_file_priv值,请使用INSTALL_SECURE_FILE_PRIVDIRCMake 选项。The default value is platform specific and depends on the value of theINSTALL_LAYOUTCMake option, as shown in the following table. To specify the defaultsecure_file_privvalue explicitly if you are building from source, use theINSTALL_SECURE_FILE_PRIVDIRCMake option.INSTALL_LAYOUT值INSTALL_LAYOUTValue默认 secure_file_priv值Defaultsecure_file_privValueSTANDALONESTANDALONE空empty DEB,RPM,SVR4/var/lib/mysql-files/var/lib/mysql-files否则Otherwise mysql-files位于CMAKE_INSTALL_PREFIX的值下mysql-filesunder theCMAKE_INSTALL_PREFIXvalue服务器在启动时会检查
secure_file_priv的值,如果该值不安全,会在错误日志中写入警告。如果非NULL值为空,或者该值为数据目录或其子目录,或者为所有用户可访问的目录,则认为该值不安全。如果secure_file_priv设置为不存在的路径,服务器会在错误日志中写入错误信息并退出。The server checks the value ofsecure_file_privat startup and writes a warning to the error log if the value is insecure. A non-NULLvalue 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. Ifsecure_file_privis set to a nonexistent path, the server writes an error message to the error log and exits.命令行格式Command-Line Format --select-into-buffer-size=#系统变量System Variable select_into_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 usingSELECT INTO OUTFILEorSELECT INTO DUMPFILEto 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_sizeoverrides any value set forread_buffer_size. (select_into_buffer_sizeandread_buffer_sizehave the same default, maximum, and minimum values.) You can also useselect_into_disk_sync_delayto 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”.
命令行格式Command-Line Format --select-into-disk-sync={ON|OFF}系统变量System Variable select_into_disk_sync范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFF有效值Valid Values OFFOFFONON当设置为
ON时,启用使用select_into_buffer_size进行缓冲同步,将长期运行的SELECT INTO OUTFILE或SELECT INTO DUMPFILE语句写入输出文件。When set onON, enables buffer synchronization of writes to an output file by a long-runningSELECT INTO OUTFILEorSELECT INTO DUMPFILEstatement usingselect_into_buffer_size.命令行格式Command-Line Format --select-into-disk-sync-delay=#系统变量System Variable select_into_disk_sync_delay范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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-runningSELECT INTO OUTFILEorSELECT INTO DUMPFILEstatement is enabled byselect_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”.
命令行格式Command-Line Format --session-track-gtids=value系统变量System Variable session_track_gtids范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value OFFOFF有效值Valid Values OFFOFFOWN_GTIDALL_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 forsession_track_gtidsare 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 itsgtid_executedsystem 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_gtidscannot 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”.
命令行格式Command-Line Format --session-track-schema[={OFF|ON}]系统变量System Variable session_track_schema范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --session-track-state-change[={OFF|ON}]系统变量System Variable session_track_state_change范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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系统变量。Thesession_track_state_changevariable 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 thesession_track_schemaorsession_track_system_variablessystem variable, respectively.Note将值分配给
session_track_state_change本身不被视为状态更改,也不会作为状态更改进行报告。然而,如果它的名称列在session_track_system_variables的值中,对它的任何赋值确实会通知新值。Assigning a value tosession_track_state_changeitself is not considered a state change and is not reported as such. However, if its name listed in the value ofsession_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_VARHint 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 fortime_zone,autocommit,character_set_client,character_set_results, andcharacter_set_connection. (The latter three variables are those affected bySET NAMES.)要启用显示每个处理语句的语句 ID,请使用
statement_id变量。例如:To enable display of the Statement ID for each statement processed, use thestatement_idvariable. 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, setsession_track_system_variablesto 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_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value OFFOFF有效值Valid Values OFFOFFSTATECHARACTERISTICSCHARACTERISTICS控制服务器是否跟踪当前会话中事务的状态和特性,并通知客户端以使这些信息可用。允许的
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. Thesesession_track_transaction_infovalues 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 thetransaction_isolationandtransaction_read_onlysystem variables to correctly determine the session defaults. (To track these variables, list them in the value of thesession_track_system_variablessystem variable.)有关会话状态跟踪的更多信息,请参见 第 7.1.18 节,“服务器跟踪客户端会话状态”。For more information about session state tracking, see Section 7.1.18, “Server Tracking of Client Session State”.
命令行格式Command-Line Format --set-operations-buffer-size=#系统变量System Variable set_operations_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 forINTERSECTandEXCEPToperations that use hash tables when thehash_set_operationsoptimizer switch isON. 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_VARHint 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: Thesha256_password_auto_generate_rsa_keysorcaching_sha2_password_auto_generate_rsa_keyssystem 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 thesha256_password(deprecated) orcaching_sha2_passwordplugin; 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 证书和密钥文件的自动生成。Theauto_generate_certssystem 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_VARHint 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 thesha256_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 aboutsha256_password, see Section 8.4.1.3, “SHA-256 Pluggable Authentication”.命令行格式Command-Line Format --sha256-password-proxy-users[={OFF|ON}]已弃用Deprecated 是Yes 系统变量System Variable sha256_password_proxy_users范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF此变量控制
sha256_password(已弃用)内置认证插件是否支持代理用户。除非启用了check_proxy_users系统变量,否则此设置无效。有关用户代理的信息,请参阅第 8.2.19 节,“代理用户”。This variable controls whether thesha256_password(deprecated) built-in authentication plugin supports proxy users. It has no effect unless thecheck_proxy_userssystem 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_VARHint 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 thesha256_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 aboutsha256_password(deprecated), including information about how clients specify the RSA public key, see Section 8.4.1.3, “SHA-256 Pluggable Authentication”.命令行格式Command-Line Format --shared-memory[={OFF|ON}]系统变量System Variable shared_memory范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 特定平台Platform Specific 窗口Windows 类型Type 布尔Boolean 默认值Default Value OFFOFF(仅限 Windows。)服务器是否允许共享内存连接。(Windows only.) Whether the server permits shared-memory connections.
命令行格式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_VARHint 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 isMYSQL. The name is case-sensitive.仅当服务器启动时启用了
shared_memory系统变量以支持共享内存连接时,此变量才适用。This variable applies only if the server is started with theshared_memorysystem 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.
命令行格式Command-Line Format --show-create-table-verbosity[={OFF|ON}]系统变量System Variable show_create_table_verbosity范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFFSHOW CREATE TABLE通常不会显示ROW_FORMAT表选项,如果行格式是默认格式。启用此变量会使SHOW CREATE TABLE显示ROW_FORMAT,无论它是否为默认格式。SHOW CREATE TABLEnormally does not show theROW_FORMATtable option if the row format is the default format. Enabling this variable causesSHOW CREATE TABLEto displayROW_FORMATregardless 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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON是否在
SHOW语句输出和信息模式表中显示生成的隐形主键。当该变量设置为OFF时,此类键不会显示。Whether generated invisible primary keys are visible in the output ofSHOWstatements and in Information Schema tables. When this variable is set toOFF, 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”.
命令行格式Command-Line Format --skip-external-locking[={OFF|ON}]系统变量System Variable skip_external_locking范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON如果 mysqld 使用外部锁(系统锁),则此值为
OFF;如果外部锁被禁用,则为ON。这只影响MyISAM表的访问。This isOFFif mysqld uses external locking (system locking),ONif external locking is disabled. This affects onlyMyISAMtable access.该变量可通过
--external-locking或--skip-external-locking选项设置。默认情况下,外部锁是禁用的。This variable is set by the--external-lockingor--skip-external-lockingoption. External locking is disabled by default.外部锁定仅影响
MyISAM表的访问。有关更多信息,包括可用和不可用的条件,请参见 第 10.11.5 节,“外部锁定”。External locking affects onlyMyISAMtable access. For more information, including conditions under which it can and cannot be used, see Section 10.11.5, “External Locking”.命令行格式Command-Line Format --skip-name-resolve[={OFF|ON}]系统变量System Variable skip_name_resolve范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 isOFF, mysqld resolves host names when checking client connections. If it isON, mysqld uses only IP numbers; in this case, allHostcolumn 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 theHostvalues for your accounts, clients may need to connect using an explicit--hostoption, such as--host=127.0.0.1or--host=::1.尝试连接到主机
127.0.0.1通常会解析为localhost账户。然而,如果服务器在启用skip_name_resolve时运行,这将失败。如果你计划这样做,请确保存在可以接受连接的账户。例如,要能够使用--host=127.0.0.1或--host=::1以root用户身份连接,请创建这些账户:An attempt to connect to the host127.0.0.1normally resolves to thelocalhostaccount. However, this fails if the server is run withskip_name_resolveenabled. If you plan to do that, make sure an account exists that can accept a connection. For example, to be able to connect asrootusing--host=127.0.0.1or--host=::1, create these accounts:CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY '
root-password'; CREATE USER 'root'@'::1' IDENTIFIED BY 'root-password';命令行格式Command-Line Format --skip-networking[={OFF|ON}]系统变量System Variable skip_networking范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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-tablesdisables authentication checks, the server also disables remote connections in that case by enablingskip_networking.命令行格式Command-Line Format --skip-show-database系统变量System Variable skip_show_database范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 theSHOW DATABASESstatement if they do not have theSHOW DATABASESprivilege. This can improve security if you have concerns about users being able to see databases belonging to other users. Its effect depends on theSHOW DATABASESprivilege: If the variable value isON, theSHOW DATABASESstatement is permitted only to users who have theSHOW DATABASESprivilege, and the statement displays all database names. If the value isOFF,SHOW DATABASESis permitted to all users, but displays the names of only those databases for which the user has theSHOW DATABASESor 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 withSHOW DATABASESor by examining theSCHEMATAtable ofINFORMATION_SCHEMA, except databases that have been restricted at the database level by partial revokes.命令行格式Command-Line Format --slow-launch-time=#系统变量System Variable slow_launch_time范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theSlow_launch_threadsstatus variable.命令行格式Command-Line Format --slow-query-log[={OFF|ON}]系统变量System Variable slow_query_log范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 (orOFF) to disable the log or 1 (orON) to enable the log. The destination for log output is controlled by thelog_outputsystem variable; if that value isNONE, no log entries are written even if the log is enabled.“慢” 是由
long_query_time变量的值决定的。参见 第 7.4.5 节,“慢查询日志”。“Slow” is determined by the value of thelong_query_timevariable. See Section 7.4.5, “The Slow Query Log”.命令行格式Command-Line Format --slow-query-log-file=file_name系统变量System Variable slow_query_log_file范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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, but the initial value can be changed with thehost_name-slow.log--slow_query_log_fileoption.命令行格式Command-Line Format --socket={file_name|pipe_name}--socket={file_name|pipe_name}系统变量System Variable socket范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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/mysqlfor RPMs.)在 Windows 上,该变量是用于本地客户端连接的命名管道的名称。默认值是
MySQL(不区分大小写)。On Windows, this variable is the name of the named pipe that is used for local client connections. The default value isMySQL(not case-sensitive).命令行格式Command-Line Format --sort-buffer-size=#系统变量System Variable sort_buffer_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_sizeis not specific to any storage engine and applies in a general manner for optimization. At minimum thesort_buffer_sizevalue must be large enough to accommodate fifteen tuples in the sort buffer. Also, increasing the value ofmax_sort_lengthmay require increasing the value ofsort_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 manySort_merge_passesper second inSHOW GLOBAL STATUSoutput, you can consider increasing thesort_buffer_sizevalue to speed upORDER BYorGROUP BYoperations 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 forsort_buffer_sizeis 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).系统变量System Variable sql_auto_is_null范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFF如果启用此变量,那么在成功插入自动生成的
AUTO_INCREMENT值之后,您可以通过执行以下形式的语句来找到该值:If this variable is enabled, then after a statement that successfully inserts an automatically generatedAUTO_INCREMENTvalue, you can find that value by issuing a statement of the following form:SELECT * FROM
tbl_nameWHEREauto_colIS 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 theLAST_INSERT_ID()function. For details, including the return value after a multiple-row insert, see Section 14.15, “Information Functions”. If noAUTO_INCREMENTvalue was successfully inserted, theSELECTstatement returns no row.通过使用
IS NULL比较来检索AUTO_INCREMENT值的行为被一些 ODBC 程序(如 Access)使用。请参见 获取自增值。通过将sql_auto_is_null设置为OFF可以禁用此行为。The behavior of retrieving anAUTO_INCREMENTvalue by using anIS NULLcomparison is used by some ODBC programs, such as Access. See Obtaining Auto-Increment Values. This behavior can be disabled by settingsql_auto_is_nulltoOFF.sql_auto_is_null的默认值为OFF。The default value ofsql_auto_is_nullisOFF.系统变量System Variable sql_big_selects范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 布尔Boolean 默认值Default Value ONON如果设置为
OFF,MySQL 会中止那些可能执行时间非常长的SELECT语句(也就是说,优化器估计检查的行数超过max_join_size值的语句)。当执行了不建议的WHERE语句时,这非常有用。新连接的默认值是ON,允许所有SELECT语句。If set toOFF, MySQL abortsSELECTstatements 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 ofmax_join_size). This is useful when an inadvisableWHEREstatement has been issued. The default value for a new connection isON, which permits allSELECTstatements.如果将
max_join_size系统变量设置为除DEFAULT以外的值,sql_big_selects将被设置为OFF。If you set themax_join_sizesystem variable to a value other thanDEFAULT,sql_big_selectsis set toOFF.系统变量System Variable sql_buffer_result范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFF如果启用,
sql_buffer_result强制将SELECT语句的结果放入临时表中。这有助于 MySQL 提前释放表锁,并且在将结果发送给客户端需要很长时间的情况下可能有益。默认值为OFF。If enabled,sql_buffer_resultforces results fromSELECTstatements 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 isOFF.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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF此服务器是否会向任何没有主键的
InnoDB表添加生成的隐藏主键。Whether this server adds a generated invisible primary key to anyInnoDBtable 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 settingREQUIRE_TABLE_PRIMARY_KEY_CHECK = GENERATEas part of aCHANGE REPLICATION SOURCE TOstatement, optionally specifying a replication channel.更多信息和示例,请参见 第 15.1.20.11 节,“生成的不可见主键”。For more information and examples, see Section 15.1.20.11, “Generated Invisible Primary Keys”.
系统变量System Variable sql_log_off范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 isOFF(that is, enable logging). To disable or enable general query logging for the current session, set the sessionsql_log_offvariable toONorOFF.设置此系统变量的会话值是一项受限操作。会话用户必须具有足够的权限来设置受限会话变量。请参见第 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”.
命令行格式Command-Line Format --sql-mode=name--sql-mode=name系统变量System Variable sql_mode范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_DATESANSI_QUOTESANSI_QUOTESERROR_FOR_DIVISION_BY_ZEROERROR_FOR_DIVISION_BY_ZEROHIGH_NOT_PRECEDENCEHIGH_NOT_PRECEDENCEIGNORE_SPACEIGNORE_SPACENO_AUTO_VALUE_ON_ZERONO_AUTO_VALUE_ON_ZERONO_BACKSLASH_ESCAPESNO_BACKSLASH_ESCAPESNO_DIR_IN_CREATENO_DIR_IN_CREATENO_ENGINE_SUBSTITUTIONNO_ENGINE_SUBSTITUTIONNO_UNSIGNED_SUBTRACTIONNO_UNSIGNED_SUBTRACTIONNO_ZERO_DATENO_ZERO_DATENO_ZERO_IN_DATENO_ZERO_IN_DATEONLY_FULL_GROUP_BYONLY_FULL_GROUP_BYPAD_CHAR_TO_FULL_LENGTHPAD_CHAR_TO_FULL_LENGTHPIPES_AS_CONCATPIPES_AS_CONCATREAL_AS_FLOATREAL_AS_FLOATSTRICT_ALL_TABLESSTRICT_ALL_TABLESSTRICT_TRANS_TABLESSTRICT_TRANS_TABLESTIME_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”.
NoteMySQL 安装程序可能会在安装过程中配置 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.
系统变量System Variable sql_notes范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON如果启用(默认设置),
Note级别的诊断会增加warning_count,服务器会记录它们。如果禁用,Note诊断不会增加warning_count,服务器也不会记录它们。mysqldump 包括输出以禁用此变量,从而在重新加载转储文件时不会对不影响重新加载操作完整性的事件产生警告。If enabled (the default), diagnostics ofNotelevel incrementwarning_countand the server records them. If disabled,Notediagnostics do not incrementwarning_countand 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.系统变量System Variable sql_quote_show_create范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 forSHOW CREATE TABLEandSHOW CREATE DATABASEstatements. 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”.命令行格式Command-Line Format --sql-require-primary-key[={OFF|ON}]系统变量System Variable sql_require_primary_key范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_keyapplies to both base tables andTEMPORARYtables, 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_keyhas 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 includesCREATE TABLE ... LIKE. It also includesCREATE TABLE ... SELECT, unless theCREATE TABLEpart 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 sameALTER TABLEstatement is permitted.即使表中还包含
UNIQUE NOT NULL索引,删除主键仍会失败。Dropping the primary key fails even if the table also contains aUNIQUE NOT NULLindex.尝试导入没有主键的表将失败并报错。Attempts to import a table with no primary key fail with an error.
该
REQUIRE_TABLE_PRIMARY_KEY_CHECKoption of theCHANGE REPLICATION SOURCE TOstatement enables a replica to select its own policy for primary key checks. When the option is set toONfor a replication channel, the replica always uses the valueONfor thesql_require_primary_keysystem variable in replication operations, requiring a primary key. When the option is set toOFF, the replica always uses the valueOFFfor thesql_require_primary_keysystem variable in replication operations, so that a primary key is never required, even if the source required one. When theREQUIRE_TABLE_PRIMARY_KEY_CHECKoption is set toSTREAM, which is the default, the replica uses whatever value is replicated from the source for each transaction. With theSTREAMsetting for theREQUIRE_TABLE_PRIMARY_KEY_CHECKoption, if privilege checks are in use for the replication channel, thePRIVILEGE_CHECKS_USERaccount needs privileges sufficient to set restricted session variables, so that it can set the session value for thesql_require_primary_keysystem variable. With theON或者OFFsettings, the account does not need these privileges. For more information, see Section 19.3.3, “Replication Privilege Checks”.TheREQUIRE_TABLE_PRIMARY_KEY_CHECKoption of theCHANGE REPLICATION SOURCE TOstatement enables a replica to select its own policy for primary key checks. When the option is set toONfor a replication channel, the replica always uses the valueONfor thesql_require_primary_keysystem variable in replication operations, requiring a primary key. When the option is set toOFF, the replica always uses the valueOFFfor thesql_require_primary_keysystem variable in replication operations, so that a primary key is never required, even if the source required one. When theREQUIRE_TABLE_PRIMARY_KEY_CHECKoption is set toSTREAM, which is the default, the replica uses whatever value is replicated from the source for each transaction. With theSTREAMsetting for theREQUIRE_TABLE_PRIMARY_KEY_CHECKoption, if privilege checks are in use for the replication channel, thePRIVILEGE_CHECKS_USERaccount needs privileges sufficient to set restricted session variables, so that it can set the session value for thesql_require_primary_keysystem variable. With theONorOFFsettings, the account does not need these privileges. For more information, see Section 19.3.3, “Replication Privilege Checks”.系统变量System Variable sql_safe_updates范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 布尔Boolean 默认值Default Value OFFOFF如果启用此变量,未在
WHERE子句或LIMIT子句中使用键的UPDATE和DELETE语句将产生错误。这使得可以捕获未正确使用键并可能更改或删除大量行的UPDATE和DELETE语句。默认值为OFF。If this variable is enabled,UPDATEandDELETEstatements that do not use a key in theWHEREclause or aLIMITclause produce an error. This makes it possible to catchUPDATEandDELETEstatements where keys are not used properly and that would probably change or delete a large number of rows. The default value isOFF.对于 mysql 客户端,可以使用
--safe-updates选项启用sql_safe_updates。更多信息请参见 使用安全更新模式 (--safe-updates)。For the mysql client,sql_safe_updatescan be enabled by using the--safe-updatesoption. For more information, see Using Safe-Updates Mode (--safe-updates).系统变量System Variable sql_select_limit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 整数Integer 默认值Default Value 18446744073709551615最小值Minimum Value 0最大值Maximum Value 18446744073709551615从
SELECT语句返回的最大行数。有关更多信息,请参见 使用安全更新模式 (--safe-updates)。The maximum number of rows to return fromSELECTstatements. 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 ofDEFAULT.如果一个
SELECT有LIMIT子句,则LIMIT优先于sql_select_limit的值。If aSELECThas aLIMITclause, theLIMITtakes precedence over the value ofsql_select_limit.系统变量System Variable sql_warnings范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF此变量控制单行
INSERT语句在发生警告时是否生成信息字符串。默认值为OFF。将其设置为ON可生成信息字符串。This variable controls whether single-rowINSERTstatements produce an information string if warnings occur. The default isOFF. Set the value toONto produce an information string.命令行格式Command-Line Format --ssl-ca=file_name--ssl-ca=file_name系统变量System Variable ssl_ca范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 文件名File name 默认值Default Value NULLPEM 格式的证书颁发机构(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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式Command-Line Format --ssl-capath=dir_name--ssl-capath=dir_name系统变量System Variable ssl_capath范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 OpenSSLrehashon the directory specified by this option prior to using it. On Linux systems, you can invokerehashlike this:$>
openssl rehashpath/to/directory在 Windows 平台上,您可以在命令提示符下使用
c_rehash脚本,如下所示:On Windows platforms, you can use thec_rehashscript in a command prompt, like this:\>
c_rehashpath/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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式Command-Line Format --ssl-cert=file_name--ssl-cert=file_name系统变量System Variable ssl_cert范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 withssl_certset 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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式Command-Line Format --ssl-cipher=name--ssl-cipher=name系统变量System Variable ssl_cipher范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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-SHA256ECDHE-ECDSA-AES256-GCM-SHA384ECDHE-RSA-AES128-GCM-SHA256ECDHE-RSA-AES256-GCM-SHA384ECDHE-ECDSA-CHACHA20-POLY1305ECDHE-RSA-CHACHA20-POLY1305ECDHE-ECDSA-AES256-CCMECDHE-ECDSA-AES128-CCMDHE-RSA-AES128-GCM-SHA256DHE-RSA-AES256-GCM-SHA384DHE-RSA-AES256-CCMDHE-RSA-AES128-CCMDHE-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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式Command-Line Format --ssl-crl=file_name--ssl-crl=file_name系统变量System Variable ssl_crl范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式Command-Line Format --ssl-crlpath=dir_name--ssl-crlpath=dir_name系统变量System Variable ssl_crlpath范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式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_VARHint 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_系统变量不同,它不是用于控制服务器是否允许加密连接,而是用于影响允许哪些加密操作。详见 第 8.8 节,“FIPS 支持”。Controls whether to enable FIPS mode on the server side. Thexxxssl_fips_modesystem variable differs from otherssl_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”.xxx允许的
ssl_fips_mode值如下:Thesessl_fips_modevalues 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 forssl_fips_modeisOFF. In this case, settingssl_fips_modetoONorSTRICTat 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.
命令行格式Command-Line Format --ssl-key=file_name--ssl-key=file_name系统变量System Variable ssl_key范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofALTER INSTANCE RELOAD TLSor after a restart if the variable value was persisted. See Server-Side Runtime Configuration and Monitoring for Encrypted Connections.命令行格式Command-Line Format --ssl_session_cache_mode={ON|OFF}系统变量System Variable ssl_session_cache_mode范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON有效值Valid Values ONONOFFOFF控制是否在服务器端启用会话缓存内存以及服务器生成会话票据。默认模式是
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 isON(enable session cache mode). A change to thessl_session_cache_modesystem variable has an effect only after theALTER INSTANCE RELOAD TLSstatement has been executed, or after a restart if the variable value was persisted.允许的
ssl_session_cache_mode值如下:Thesessl_session_cache_modevalues 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 isOFF. When running on OpenSSL 1.0.xthe session tickets are always generated, but the tickets are not usable whenssl_session_cache_modeis enabled.当前
ssl_session_cache_mode的生效值可以通过Ssl_session_cache_mode状态变量进行观察。The current value in effect forssl_session_cache_modecan be observed with theSsl_session_cache_modestatus variable.命令行格式Command-Line Format --ssl_session_cache_timeout系统变量System Variable ssl_session_cache_timeout范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thessl_session_cache_modesystem 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 thessl_session_cache_timeoutsystem variable has an effect only after theALTER INSTANCE RELOAD TLSstatement has been executed, or after a restart if the variable value was persisted. The current value in effect forssl_session_cache_timeoutcan be observed with theSsl_session_cache_timeoutstatus variable.系统变量System Variable statement_id范围Scope 会议Session 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 thesession_track_system_variablessystem variable to identify this statement in Performance Schema tables such as theevents_statements_historytable.命令行格式Command-Line Format --stored-program-cache=#系统变量System Variable stored_program_cache范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_VARHint 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 bystored_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 thestored_program_cacheoption.stored_program_cache选项为每个连接缓存的存储过程或函数的数量设置一个软上限,并且每次连接执行存储过程或函数时都会检查该限制。而存储程序定义缓存分区则是一个共享缓存,用于存储其他用途的存储程序定义对象。存储程序定义缓存分区中对象的存在与存储过程缓存或存储函数缓存中对象的存在相互独立,反之亦然。Thestored_program_cacheoption 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”.
命令行格式Command-Line Format --super-read-only[={OFF|ON}]系统变量System Variable super_read_only范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theread_onlysystem variable is enabled, the server permits no client updates except from users who have theCONNECTION_ADMINprivilege (or the deprecatedSUPERprivilege). If thesuper_read_onlysystem variable is also enabled, the server prohibits client updates even from users who haveCONNECTION_ADMINorSUPER. See the description of theread_onlysystem variable for a description of read-only mode and information about howread_onlyandsuper_read_onlyinteract.当启用
super_read_only时,客户端更新被阻止的操作包括那些不一定看起来像更新的操作,例如CREATE FUNCTION(用于安装可加载函数)、INSTALL PLUGIN和INSTALL COMPONENT。这些操作被禁止,因为它们涉及对mysql系统架构中的表进行更改。Client updates prevented whensuper_read_onlyis enabled include operations that do not necessarily appear to be updates, such asCREATE FUNCTION(to install a loadable function),INSTALL PLUGIN, andINSTALL COMPONENT. These operations are prohibited because they involve changes to tables in themysqlsystem schema.同样,如果事件调度器已启用,启用
super_read_only系统变量将阻止其更新events数据字典表中的事件 “最后执行时间”。这会导致事件调度器在下一次尝试执行计划事件时停止,并在写入服务器错误日志后停止。(在这种情况下,event_scheduler系统变量不会从ON变为OFF。其含义是,该变量会拒绝 DBA 对事件调度器启用或禁用的 意图,而事件调度器实际的启动或停止状态可能不同。)如果在启用之后随后禁用super_read_only,服务器会根据需要自动重新启动事件调度器。Similarly, if the Event Scheduler is enabled, enabling thesuper_read_onlysystem variable prevents it from updating event “last executed” timestamps in theeventsdata 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 theevent_schedulersystem variable does not change fromONtoOFF. 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.). Ifsuper_read_onlyis subsequently disabled after being enabled, the server automatically restarts the Event Scheduler as needed.对复制源服务器上的
super_read_only所做的更改不会复制到副本服务器。该值可以在副本上独立设置,而不受源服务器设置的影响。Changes tosuper_read_onlyon 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.命令行格式Command-Line Format --syseventlog.facility=value--syseventlog.facility=value系统变量System Variable syseventlog.facility范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 默认值Default Value daemon将错误日志输出到
syslog的功能(发送消息的程序类型)。除非安装了log_sink_syseventlog错误日志组件,否则该变量不可用。请参见 第 7.4.2.8 节,“将错误日志记录到系统日志”。The facility for error log output written tosyslog(what type of program is sending the message). This variable is unavailable unless thelog_sink_syseventlogerror 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 systemsyslogdocumentation.该变量在 Windows 上不存在。This variable does not exist on Windows.
命令行格式Command-Line Format --syseventlog.include-pid[={OFF|ON}]系统变量System Variable syseventlog.include_pid范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 tosyslog. This variable is unavailable unless thelog_sink_syseventlogerror log component is installed. See Section 7.4.2.8, “Error Logging to the System Log”.该变量在 Windows 上不存在。This variable does not exist on Windows.
命令行格式Command-Line Format --syseventlog.tag=tag系统变量System Variable syseventlog.tag范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 tosyslogor the Windows Event Log. This variable is unavailable unless thelog_sink_syseventlogerror log component is installed. See Section 7.4.2.8, “Error Logging to the System Log”.默认情况下,不会设置任何标签,因此服务器标识在 Windows 上只是
MySQL,在其他平台上是mysqld。如果指定了标签值tag,它将附加到服务器标识后面,前面带一个连字符,从而生成syslog标识为mysqld-(在 Windows 上为tagMySQL-)。By default, no tag is set, so the server identifier is simplytagMySQLon Windows, andmysqldon other platforms. If a tag value oftagis specified, it is appended to the server identifier with a leading hyphen, resulting in asyslogidentifier ofmysqld-(ortagMySQL-on Windows).tag在 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_zonesystem_time_zone系统变量System Variable system_time_zonesystem_time_zone范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 setsystem_time_zone. To explicitly specify the system time zone, set theTZenvironment variable or use the--timezoneoption 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_zonereflects that change, which has these implications for applications:引用
system_time_zone的查询在夏令时改变前会得到一个值,而在改变后会得到另一个值。Queries that referencesystem_time_zonewill 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, thesystem_time_zoneremains constant within the query because the value is usually cached at the beginning of execution.
system_time_zone变量与time_zone变量不同。虽然它们可能有相同的值,但后者变量用于初始化每个连接的客户端的时区。请参见 第 7.1.15 节,“MySQL 服务器时区支持”。Thesystem_time_zonevariable differs from thetime_zonevariable. 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”.命令行格式Command-Line Format --table-definition-cache=#系统变量System Variable table_definition_cache范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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设置作为字典对象缓存中表实例数量以及一次可以打开的每表文件表空间数量的软限制。ForInnoDB, thetable_definition_cachesetting 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 thetable_definition_cachelimit, 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 thetable_definition_cachelimit 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 thetable_definition_cacheandinnodb_open_filessettings. If both variables are set, the highest setting is used. If neither variable is set, thetable_definition_cachesetting, which has a higher default value, is used. If the number of open tablespaces exceeds the limit defined bytable_definition_cacheorinnodb_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_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF控制在创建或修改具有与
default_table_encryption设置不同的加密模式的模式或通用表空间时,或者在创建或修改具有不同于默认模式加密设置的表时发生的TABLE_ENCRYPTION_ADMIN权限检查。该检查默认情况下为禁用。Controls theTABLE_ENCRYPTION_ADMINprivilege check that occurs when creating or altering a schema or general tablespace with encryption that differs from thedefault_table_encryptionsetting, 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权限。Settingtable_encryption_privilege_checkat runtime requires theSUPERprivilege.table_encryption_privilege_check支持SET PERSIST和SET PERSIST_ONLY语法。详见 第 7.1.9.3 节,“持久化系统变量”。table_encryption_privilege_checksupportsSET PERSISTandSET PERSIST_ONLYsyntax. See Section 7.1.9.3, “Persisted System Variables”.更多信息,请参见 为模式和通用表空间定义加密默认值。For more information, see Defining an Encryption Default for Schemas and General Tablespaces.
命令行格式Command-Line Format --table-open-cache=#系统变量System Variable table_open_cache范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofopen_files_limit- 10 -the effective value ofmax_connections/ 2, and 400; that isMAX( (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 theOpened_tablesstatus variable. If the value ofOpened_tablesis large and you do not useFLUSH TABLESoften (which just forces all tables to be closed and reopened), then you should increase the value of thetable_open_cachevariable. For more information about the table cache, see Section 10.4.3.1, “How MySQL Opens and Closes Tables”.命令行格式Command-Line Format --table-open-cache-instances=#系统变量System Variable table_open_cache_instances范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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 sizetable_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 fortable_open_cache_instancesmight lead to excessive memory usage. In that situation, it can be helpful to settable_open_cache_instancesto 1 in order to restrict memory usage.命令行格式Command-Line Format --tablespace-definition-cache=#系统变量System Variable tablespace_definition_cache范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 bytablespace_definition_cache.设置为
0意味着表空间定义对象仅在使用时保存在字典对象缓存中。A setting of0means 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”.
命令行格式Command-Line Format --temptable-max-mmap=#系统变量System Variable temptable_max_mmap范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 toInnoDBinternal 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.
命令行格式Command-Line Format --temptable-max-ram=#系统变量System Variable temptable_max_ram范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theTempTablestorage 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.
命令行格式Command-Line Format --temptable-use-mmap[={OFF|ON}]已弃用Deprecated 是Yes 系统变量System Variable temptable_use_mmap范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 thetemptable_max_ramvariable. Whentemptable_use_mmapis disabled (default), the TempTable storage engine usesInnoDBon-disk internal temporary tables instead. For more information, see Section 10.4.4, “Internal Temporary Table Use in MySQL”.thread_cache_sizethread_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_VARHint 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 thanthread_cache_sizethreads 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 setthread_cache_sizehigh enough so that most new connections use cached threads. By examining the difference between theConnectionsandThreads_createdstatus 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)
命令行格式Command-Line Format --thread-handling=name系统变量System Variable thread_handling范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value one-thread-per-connectionone-thread-per-connection有效值Valid Values no-threadsno-threadsone-thread-per-connectionone-thread-per-connectionloaded-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 areno-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), andloaded-dynamically(set by the thread pool plugin when it initializes).no-threadsis useful for debugging under Linux; see Section 7.9, “Debugging MySQL”.命令行格式Command-Line Format --thread-pool-algorithm=#系统变量System Variable thread_pool_algorithm范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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_VARHint 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。Enablingthread_pool_dedicated_listenersis only useful when a transaction limit is defined bythread_pool_max_transactions_limit. Otherwise,thread_pool_dedicated_listenersshould 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_VARHint 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”.
命令行格式Command-Line Format --thread-pool-longrun-trx-limit=#系统变量System Variable thread_pool_longrun_trx_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 整数Integer 默认值Default Value 2000最小值Minimum Value 10最大值Maximum Value 60*60*24单位Unit 毫秒ms 当
thread_pool_max_transactions_limit被使用时,每个线程组中可以同时活动的事务数量是有限的。如果所有可用数量都被长时间运行的事务占用,则分配给该组的任何额外事务都会被阻塞,直到其中一个长时间运行的事务完成,这会让用户感到无法理解的卡顿。Whenthread_pool_max_transactions_limitis 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 bythread_pool_longrun_trx_limit. When the number of long-running transactions decreases,thread_pool_max_transactions_limitcan be (and is) enabled again. In order for this to happen, the number of ongoing transactions must be less thanthread_pool_max_transactions_limit / 2for 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_VARHint 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_VARHint 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. TheCONNECTION_ADMINprivilege is required to configurethread_pool_max_transactions_limitat runtime.当您定义事务限制时,启用
thread_pool_dedicated_listeners会在每个线程组中创建一个专用的监听器线程。额外的专用监听器线程会消耗更多资源并影响线程池性能。因此,应谨慎使用thread_pool_dedicated_listeners。When you define a transaction limit, enablingthread_pool_dedicated_listenerscreates a dedicated listener thread in each thread group. The additional dedicated listener thread consumes more resources and affects thread pool performance.thread_pool_dedicated_listenersshould therefore be used cautiously.当达到
thread_pool_max_transactions_limit定义的限制时,新的连接或现有连接上的事务可能会出现挂起,直到一个或多个现有事务完成。在许多情况下,可以通过设置thread_pool_longrun_trx_limit来缓解此问题,以便在持续一段时间的给定数量的进行中事务达到限制时放宽事务最大值。如果在尝试此操作后,现有连接仍然被阻塞或长时间运行,可能需要使用特权连接访问服务器,以增加限制、移除限制或终止正在运行的事务。请参阅特权连接。When the limit defined bythread_pool_max_transactions_limithas 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 settingthread_pool_longrun_trx_limitso 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_VARHint 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 ofNwhereNis greater than 0 means 1 consumer thread andN−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”.
命令行格式Command-Line Format --thread-pool-prio-kickup-timer=#系统变量System Variable thread_pool_prio_kickup_timer范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_VARHint 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 ifthread_pool_max_transactions_limitis set,thread_pool_query_threads_per_groupmust 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权限。TheCONNECTION_ADMINprivilege is required to configurethread_pool_query_threads_per_groupat runtime.如果在运行时减少
thread_pool_query_threads_per_group的值,当前正在运行用户查询的线程将被允许完成,然后移至备用池或被终止。如果在运行时增加该值,并且线程组需要更多线程,这些线程将尽可能从备用池中获取,否则将被创建。If you decrease the value ofthread_pool_query_threads_per_groupat 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.
命令行格式Command-Line Format --thread-pool-size=#系统变量System Variable thread_pool_size范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --thread-pool-stall-limit=#系统变量System Variable thread_pool_stall_limit范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --thread-pool-transaction-delay系统变量System Variable thread_pool_transaction_delay范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 bythread_pool_transaction_delaybefore executing a new transaction.thread_pool_transaction_delay设置不会影响从特权连接(分配到Admin线程组的连接)发出的查询。这些查询不受配置的事务延迟影响。Thethread_pool_transaction_delaysetting does not affect queries issued from a privileged connection (a connection assigned to theAdminthread group). These queries are not subject to a configured transaction delay.命令行格式Command-Line Format --thread-stack=#系统变量System Variable thread_stack范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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.
系统变量System Variable time_zonetime_zone范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 ofsystem_time_zone”). The value can be specified explicitly at server startup with the--default-time-zoneoption. See Section 7.1.15, “MySQL Server Time Zone Support”.Note如果设置为
SYSTEM,每个需要进行时区计算的 MySQL 函数调用都会调用系统库以确定当前的系统时区。此调用可能受到全局互斥锁保护,从而导致竞争。If set toSYSTEM, 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.系统变量System Variable timestamp范围Scope 会议Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_valueshould be a Unix epoch timestamp (a value like that returned byUNIX_TIMESTAMP(), not a value in'format) orYYYY-MM-DD hh:mm:ss'DEFAULT.将
timestamp设置为常量值会使其保持该值,直到再次更改。将timestamp设置为DEFAULT会使其值为访问时的当前日期和时间。Settingtimestampto a constant value causes it to retain that value until it is changed again. SettingtimestamptoDEFAULTcauses 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数据类型相同。timestampis aDOUBLErather thanBIGINTbecause its value includes a microseconds part. The maximum value corresponds to'2038-01-19 03:14:07'UTC, the same as for theTIMESTAMPdata type.SET timestamp会影响NOW()返回的值,但不会影响SYSDATE()。这意味着二进制日志中的时间戳设置不会影响SYSDATE()的调用。服务器可以使用--sysdate-is-now选项启动,使SYSDATE()成为NOW()的同义词,在这种情况下SET timestamp会影响这两个函数。SET timestampaffects the value returned byNOW()but not bySYSDATE(). This means that timestamp settings in the binary log have no effect on invocations ofSYSDATE(). The server can be started with the--sysdate-is-nowoption to causeSYSDATE()to be a synonym forNOW(), in which caseSET timestampaffects 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_VARHint 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. Thetls_certificates_enforced_validationsystem 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-validationoption on the command line with or without theONvalue. With validation enforcement enabled, certificates are also validated at the time of reloading them through theALTER INSTANCE RELOAD TLSstatement. This system variable cannot be persisted across reboots. For more information, see Configuring Certificate Validation Enforcement.命令行格式Command-Line Format --tls-ciphersuites=ciphersuite_list--tls-ciphersuites=ciphersuite_list系统变量System Variable tls_ciphersuites范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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_SHA256TLS_AES_256_GCM_SHA384TLS_CHACHA20_POLY1305_SHA256TLS_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 isNULL, 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”.命令行格式Command-Line Format --tls-version=protocol_list--tls-version=protocol_list系统变量System Variable tls_version范围Scope 全球Global 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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.
ImportantMySQL 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 isTLSv1.2.
将此变量设置为空字符串将禁用加密连接。Setting this variable to an empty string disables encrypted connections.
命令行格式Command-Line Format --tmp-table-size=#系统变量System Variable tmp_table_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 theMEMORYandTempTablestorage 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表。Thetmp_table_sizevariable does not apply to user-createdMEMORYtables. User-createdTempTabletables are not supported.当使用
MEMORY存储引擎来处理内部内存临时表时,实际大小限制为tmp_table_size和max_heap_table_size中的较小值。max_heap_table_size设置不适用于TempTable表。When using theMEMORYstorage engine for internal in-memory temporary tables, the actual size limit is the smaller oftmp_table_sizeandmax_heap_table_size. Themax_heap_table_sizesetting does not apply toTempTabletables.如果你执行许多高级的
GROUP BY查询并且有大量内存,请增加tmp_table_size的值(以及在使用MEMORY存储引擎处理内部内存临时表时,如有必要,也增加max_heap_table_size)。Increase the value oftmp_table_size(andmax_heap_table_sizeif necessary when using theMEMORYstorage engine for internal in-memory temporary tables) if you do many advancedGROUP BYqueries 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 comparingCreated_tmp_disk_tablesandCreated_tmp_tablesvalues.另请参见 第 10.4.4 节,“MySQL 中的内部临时表使用”。See also Section 10.4.4, “Internal Temporary Table Use in MySQL”.
命令行格式Command-Line Format --tmpdir=dir_name--tmpdir=dir_name系统变量System Variable tmpdir范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint 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/tmpdirectory 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语句的临时文件存储在此目录中,因此使用永久位置它们可以在机器重启后仍然存在,尽管即使临时文件被删除,复制在重启之后仍然可以继续。tmpdircan 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 fortmpdir, consider setting a different temporary directory for the replica using thereplica_load_tmpdirvariable. For a replica, the temporary files used to replicateLOAD DATAstatements 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”.
命令行格式Command-Line Format --transaction-alloc-block-size=#系统变量System Variable transaction_alloc_block_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 oftransaction_prealloc_size.命令行格式Command-Line Format --transaction-isolation=name系统变量System Variable transaction_isolation范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 枚举Enumeration 默认值Default Value REPEATABLE-READREPEATABLE-READ有效值Valid Values READ-UNCOMMITTEDREAD-UNCOMMITTEDREAD-COMMITTEDREAD-COMMITTEDREPEATABLE-READREPEATABLE-READSERIALIZABLESERIALIZABLE事务隔离级别。默认值是
REPEATABLE-READ。The transaction isolation level. The default isREPEATABLE-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-isolationserver option.在运行时,可以直接使用
SET语句为transaction_isolation系统变量分配值,或者间接使用SET TRANSACTION语句。如果你直接将transaction_isolation设置为包含空格的隔离级别名称,则名称应使用引号括起来,并将空格替换为连字符。例如,使用以下SET语句来设置全局值:At runtime, the isolation level can be set directly using theSETstatement to assign a value to thetransaction_isolationsystem variable, or indirectly using theSET TRANSACTIONstatement. If you settransaction_isolationdirectly 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 thisSETstatement to set the global value:SET GLOBAL transaction_isolation = 'READ-COMMITTED';
设置全局
transaction_isolation值会为所有后续会话设置隔离级别。现有会话不受影响。Setting the globaltransaction_isolationvalue sets the isolation level for all subsequent sessions. Existing sessions are unaffected.要设置会话或下一级
transaction_isolation值,请使用SET语句。对于大多数会话系统变量,这些语句是设置值的等效方式:To set the session or next-leveltransaction_isolationvalue, use theSETstatement. For most session system variables, these statements are equivalent ways to set the value:SET @@SESSION.
var_name=value; SET SESSIONvar_name=value; SETvar_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,SETsyntax for assigning session system variable values has nonstandard semantics fortransaction_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 toSET SESSION TRANSACTION ISOLATION LEVEL(with theSESSIONkeyword).
要设置下一事务的隔离级别,请使用以下语法: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 toSET TRANSACTION ISOLATION LEVEL(without theSESSIONkeyword).
有关
SET TRANSACTION及其与transaction_isolation系统变量的关系的更多信息,请参见 第 15.3.7 节,“SET TRANSACTION 语句”。For more information aboutSET TRANSACTIONand its relationship to thetransaction_isolationsystem variable, see Section 15.3.7, “SET TRANSACTION Statement”.命令行格式Command-Line Format --transaction-prealloc-size=#已弃用Deprecated 是Yes 系统变量System Variable transaction_prealloc_size范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 istransaction_prealloc_size. For every allocation that cannot be satisfied from the pool because it has insufficient memory available, the pool is increased bytransaction_alloc_block_sizebytes. When the transaction ends, the pool is truncated totransaction_prealloc_sizebytes. By makingtransaction_prealloc_sizesufficiently large to contain all statements within a single transaction, you can avoid manymalloc()calls.transaction_prealloc_size已被弃用,设置此变量不再有效。预计transaction_prealloc_size将在 MySQL 的未来版本中移除。transaction_prealloc_sizeis deprecated, and setting this variable no longer has any effect. Expecttransaction_prealloc_sizeto be removed in a future release of MySQL.命令行格式Command-Line Format --transaction-read-only[={OFF|ON}]系统变量System Variable transaction_read_only范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value OFFOFF事务访问模式。其值可以是
OFF(读/写;默认)或ON(只读)。The transaction access mode. The value can beOFF(read/write; the default) orON(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-onlyserver option.在运行时,可以直接使用
SET语句为transaction_read_only系统变量赋值,或者间接使用SET TRANSACTION语句。例如,使用此SET语句设置全局值:At runtime, the access mode can be set directly using theSETstatement to assign a value to thetransaction_read_onlysystem variable, or indirectly using theSET TRANSACTIONstatement. For example, use thisSETstatement to set the global value:SET GLOBAL transaction_read_only = ON;
设置全局
transaction_read_only值会为所有后续会话设置访问模式。现有会话不受影响。Setting the globaltransaction_read_onlyvalue sets the access mode for all subsequent sessions. Existing sessions are unaffected.要设置会话或下一级的
transaction_read_only值,请使用SET语句。对于大多数会话系统变量,这些语句是设置值的等效方式:To set the session or next-leveltransaction_read_onlyvalue, use theSETstatement. For most session system variables, these statements are equivalent ways to set the value:SET @@SESSION.
var_name=value; SET SESSIONvar_name=value; SETvar_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,SETsyntax for assigning session system variable values has nonstandard semantics fortransaction_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 toSET SESSION TRANSACTION {READ WRITE | READ ONLY}(with theSESSIONkeyword).
要设置下一个事务的访问模式,请使用此语法: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 toSET TRANSACTION {READ WRITE | READ ONLY}(without theSESSIONkeyword).
有关
SET TRANSACTION及其与transaction_read_only系统变量的关系的更多信息,请参阅 第 15.3.7 节,“SET TRANSACTION 语句”。For more information aboutSET TRANSACTIONand its relationship to thetransaction_read_onlysystem variable, see Section 15.3.7, “SET TRANSACTION Statement”.系统变量System Variable unique_checks范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies是Yes 类型Type 布尔Boolean 默认值Default Value ONON如果设置为 1(默认值),则会对
InnoDB表中的二级索引执行唯一性检查。如果设置为 0,则允许存储引擎假定输入数据中不存在重复键。如果你确定你的数据不包含唯一性冲突,可以将其设置为 0,以加快大表导入InnoDB的速度。If set to 1 (the default), uniqueness checks for secondary indexes inInnoDBtables 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 toInnoDB.将此变量设置为 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.
命令行格式Command-Line Format --updatable-views-with-limit[={OFF|ON}]系统变量System Variable updatable_views_with_limit范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 aLIMITclause. (Such updates often are generated by GUI tools.) An update is anUPDATEorDELETEstatement. Primary key here means aPRIMARY KEY, or aUNIQUEindex in which no column can containNULL.该变量可以有两个值:The variable can have two values:
1或YES:仅发出警告(不是错误信息)。这是默认值。1orYES: Issue a warning only (not an error message). This is the default value.0或NO:禁止更新。0orNO: Prohibit the update.
仅用于 MySQL HeatWave。有关更多信息,请参阅 系统变量。For use with MySQL HeatWave only. See System Variables, for more information.
validate_password.xxxvalidate_password组件实现了一组系统变量,这些变量的名称形式为validate_password.。这些变量会影响该组件的密码测试;参见 第 8.4.3.2 节,“密码验证选项和变量”。Thexxxvalidate_passwordcomponent implements a set of system variables having names of the formvalidate_password.. These variables affect password testing by that component; see Section 8.4.3.2, “Password Validation Options and Variables”.xxx服务器的版本号。该值还可能包含表示服务器构建或配置信息的后缀。
-debug表示服务器是在启用调试支持的情况下构建的。The version number for the server. The value might also include a suffix indicating server build or configuration information.-debugindicates that the server was built with debugging support enabled.系统变量System Variable version_comment范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String CMake 配置程序有一个
COMPILATION_COMMENT_SERVER选项,允许在构建 MySQL 时指定注释。该变量包含该注释的值。The CMake configuration program has aCOMPILATION_COMMENT_SERVERoption that permits a comment to be specified when building MySQL. This variable contains the value of that comment.系统变量System Variable version_compile_machine范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 服务器二进制文件的类型。The type of the server binary.
系统变量System Variable version_compile_os范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String MySQL 构建时使用的操作系统类型。The type of operating system on which MySQL was built.
系统变量System Variable version_compile_zlib范围Scope 全球Global 动态Dynamic 否No SET_VAR提示适用SET_VARHint Applies否No 类型Type 字符串String 编译内置的
zlib库的版本。The version of the compiled-inzliblibrary.命令行格式Command-Line Format --wait-timeout=#系统变量System Variable wait_timeout范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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 sessionwait_timeoutvalue is initialized from the globalwait_timeoutvalue or from the globalinteractive_timeoutvalue, depending on the type of client (as defined by theCLIENT_INTERACTIVEconnect option tomysql_real_connect()). See alsointeractive_timeout.从最后生成消息的语句产生的错误、警告和注意事项的数量。此变量为只读。参见 第 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”.
命令行格式Command-Line Format --windowing-use-high-precision[={OFF|ON}]系统变量System Variable windowing_use_high_precision范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint 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”.
命令行格式Command-Line Format --xa-detach-on-prepare[={OFF|ON}]系统变量System Variable xa_detach_on_prepare范围Scope 全局,会话Global, Session 动态Dynamic 是Yes SET_VAR提示适用SET_VARHint Applies否No 类型Type 布尔Boolean 默认值Default Value ONON当设置为
ON(启用)时,所有 XA 事务都会在XA PREPARE的一部分中从连接(会话)中分离(断开)。这意味着,即使原始连接尚未终止,XA 事务也可以由另一个连接提交或回滚,而且该连接可以启动新的事务。When set toON(enabled), all XA transactions are detached (disconnected) from the connection (session) as part ofXA 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 isOFF(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”.