5.1.8 Server System Variables服务器系统变量

The MySQL server maintains many system variables that configure its operation. Each system variable has a default value. System variables can be set at server startup using options on the command line or in an option file.MySQL服务器维护许多配置其操作的系统变量。每个系统变量都有一个默认值。系统变量可以在服务器启动时使用命令行或选项文件中的选项进行设置。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. You can also use system variable values in expressions.其中大多数可以在运行时使用SET语句动态更改,这使您可以在不必停止和重新启动服务器的情况下修改服务器的操作。您还可以在表达式中使用系统变量值。

Setting a global system variable runtime value normally requires the SYSTEM_VARIABLES_ADMIN privilege (or the deprecated SUPER privilege).设置全局系统变量运行时值通常需SYSTEM_VARIABLES_ADMIN权限(或不推荐使用的SUPER权限)。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 5.1.9.1, “System Variable Privileges”有关更多信息,请参阅第5.1.9.1节,“系统变量权限”

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

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

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

Note注意

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. 这些变量可以通过SET语句设置为ON1来启用,也可以通过设置为OFF0来禁用。Boolean variables can be set at startup to the values ON, TRUE, OFF, and FALSE (not case-sensitive), as well as 1 and 0. 布尔变量可以在启动时设置为ONTRUEOFFFALSE(不区分大小写)以及10See Section 4.2.2.4, “Program Option Modifiers”.请参阅第4.2.2.4节,“程序选项修改器”

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.服务器也有可能向上调整一个值。例如,如果将值0分配给最小值为1024的变量,则服务器会将该值设置为1024。

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

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.除非另有指定,否则如果值是相对路径名,则默认文件位置为数据目录。若要明确指定位置,请使用绝对路径名。假设数据目录是/var/mysql/dataIf a file-valued variable is given as a relative path name, it is located under /var/mysql/data.如果一个文件值变量被指定为相对路径名,那么它位于/var/mysql/data下。If the value is an absolute path name, its location is as given by the path name.如果该值是绝对路径名,则其位置由路径名给定。