4.9 Environment Variables环境变量

This section lists environment variables that are used directly or indirectly by MySQL. Most of these can also be found in other places in this manual.本节列出MySQL直接或间接使用的环境变量。其中大部分内容也可以在本手册的其他地方找到。

Options on the command line take precedence over values specified in option files and environment variables, and values in option files take precedence over values in environment variables. 命令行上的选项优先于选项文件和环境变量中指定的值,选项文件中的值优先于环境变量中的值。In many cases, it is preferable to use an option file instead of environment variables to modify the behavior of MySQL. See Section 4.2.2.2, “Using Option Files”.在许多情况下,最好使用选项文件而不是环境变量来修改MySQL的行为。请参阅第4.2.2.2节,“使用选项文件”

VariableDescription描述
AUTHENTICATION_LDAP_CLIENT_LOGClient-side LDAP authentication logging level.客户端LDAP身份验证日志级别。
AUTHENTICATION_PAM_LOGPAM authentication plugin debug logging settings.身份验证插件调试日志记录设置。
CCThe name of your C compiler (for running CMake).C编译器的名称(用于运行CMake)。
CXXThe name of your C++ compiler (for running CMake).C++编译器的名称(用于运行CMake)。
CCThe name of your C compiler (for running CMake).C编译器的名称(用于运行CMake)。
DBI_USERThe default user name for Perl DBI.Perl DBI的默认用户名。
DBI_TRACETrace options for Perl DBI.Perl DBI的跟踪选项。
HOMEThe default path for the mysql history file is $HOME/.mysql_history.mysql历史文件的默认路径是$HOME/.mysql_history
LD_RUN_PATHUsed to specify the location of libmysqlclient.so.用于指定libmysqlclientso的位置。
LIBMYSQL_ENABLE_CLEARTEXT_PLUGINEnable mysql_clear_password authentication plugin; see Section 6.4.1.4, “Client-Side Cleartext Pluggable Authentication”.启用mysql_clear_password身份验证插件;请参阅第6.4.1.4节,“客户端明文可插拔身份验证”
LIBMYSQL_PLUGIN_DIRDirectory in which to look for client plugins.查找客户端插件的目录。
LIBMYSQL_PLUGINSClient plugins to preload.要预加载的客户端插件。
MYSQL_DEBUGDebug trace options when debugging.调试时调试跟踪选项。
MYSQL_GROUP_SUFFIXOption group suffix value (like specifying --defaults-group-suffix).选项组后缀值(如指定--defaults-group-suffix)。
MYSQL_HISTFILEThe path to the mysql history file. If this variable is set, its value overrides the default for $HOME/.mysql_history.mysql历史文件的路径。如果设置了此变量,其值将覆盖$HOME/.mysql_history的默认值。
MYSQL_HISTIGNOREPatterns specifying statements that mysql should not log to $HOME/.mysql_history, or syslog if --syslog is given.指定mysql不应记录到$HOME/.mysql_history或syslog(如果给出--syslog)的语句的模式。
MYSQL_HOMEThe path to the directory in which the server-specific my.cnf file resides.服务器特定my.cnf文件所在目录的路径。
MYSQL_HOSTThe default host name used by the mysql command-line client.mysql命令行客户端使用的默认主机名。
MYSQL_OPENSSL_UDF_DH_BITS_THRESHOLDMaximum key length for create_dh_parameters(). create_dh_parameters()的最大键长。See Section 6.6.2, “MySQL Enterprise Encryption Usage and Examples”.请参阅第6.6.2节,“MySQL企业加密用法和示例”
MYSQL_OPENSSL_UDF_DSA_BITS_THRESHOLDMaximum DSA key length for create_asymmetric_priv_key(). See Section 6.6.2, “MySQL Enterprise Encryption Usage and Examples”.create_asymmetric_priv_key()的最大DSA密钥长度。请参阅第6.6.2节,“MySQL企业加密用法和示例”
MYSQL_OPENSSL_UDF_RSA_BITS_THRESHOLDMaximum RSA key length for create_asymmetric_priv_key(). create_asymmetric_priv_key()的最大RSA密钥长度。See Section 6.6.2, “MySQL Enterprise Encryption Usage and Examples”.请参阅第6.6.2节,“MySQL企业加密用法和示例”
MYSQL_PS1The command prompt to use in the mysql command-line client.mysql命令行客户端中使用的命令提示符
MYSQL_PWDThe default password when connecting to mysqld. Using this is insecure. See note following table.连接到mysqld时的默认密码。使用它是不安全的。见下表注释。
MYSQL_TCP_PORTThe default TCP/IP port number.默认TCP/IP端口号。
MYSQL_TEST_LOGIN_FILEThe name of the .mylogin.cnf login path file..mylogin.cnf登录路径文件的名称。
MYSQL_TEST_TRACE_CRASHWhether the test protocol trace plugin crashes clients. See note following table.测试协议跟踪插件是否导致客户端崩溃。见下表注释。
MYSQL_TEST_TRACE_DEBUGWhether the test protocol trace plugin produces output. See note following table.测试协议跟踪插件是否产生输出。见下表注释。
MYSQL_UNIX_PORTThe default Unix socket file name; used for connections to localhost.默认的Unix套接字文件名;用于连接到localhost
MYSQLX_TCP_PORTThe X Plugin default TCP/IP port number.X插件的默认TCP/IP端口号。
MYSQLX_UNIX_PORTThe X Plugin default Unix socket file name; used for connections to localhost.X插件默认Unix套接字文件名;用于连接到localhost
NOTIFY_SOCKETSocket used by mysqld to communicate with systemd.mysqld用于与systemd通信的套接字。
PATHUsed by the shell to find MySQL programs.由shell用于查找MySQL程序。
PKG_CONFIG_PATHLocation of mysqlclient.pc pkg-config file. See note following table.mysqlclient.pc pkg-config文件的位置。见下表注释。
TMPDIRThe directory in which temporary files are created.创建临时文件的目录。
TZThis should be set to your local time zone. See Section B.3.3.7, “Time Zone Problems”.这应该设置为您的本地时区。请参见第B.3.3.7节,“时区问题”
UMASKThe user-file creation mode when creating files. See note following table.创建文件时的用户文件创建模式。见下表注释。
UMASK_DIRThe user-directory creation mode when creating directories. See note following table.创建目录时的用户目录创建模式。见下表注释。
USERThe default user name on Windows when connecting to mysqld.连接到mysqld时Windows上的默认用户名。

For information about the mysql history file, see Section 4.5.1.3, “mysql Client Logging”.有关mysql历史文件的信息,请参阅第4.5.1.3节,“mysql客户端日志记录”

Use of MYSQL_PWD to specify a MySQL password must be considered extremely insecure and should not be used. 使用MY_RESPWD指定MYSQL密码必须被视为极其不安全,不应使用。Some versions of ps include an option to display the environment of running processes. ps的某些版本包含一个显示运行进程环境的选项。On some systems, if you set MYSQL_PWD, your password is exposed to any other user who runs ps. Even on systems without such a version of ps, it is unwise to assume that there are no other methods by which users can examine process environments.在某些系统上,如果您设置了MY_RESPWD,您的密码将暴露给运行ps的任何其他用户。即使在没有这种ps版本的系统上,假设用户没有其他方法可以检查流程环境也是不明智的。

MYSQL_PWD is deprecated as of MySQL 8.0; expect it to be removed in a future version of MySQL.MYSQL 8.0版本已弃用MYSQL_PWD;预计它将在MySQL的未来版本中被删除。

MYSQL_TEST_LOGIN_FILE is the path name of the login path file (the file created by mysql_config_editor). MYSQL_TEST_LOGIN_FILE是登录路径文件(由mysql_config_editor创建的文件)的路径名。If not set, the default value is %APPDATA%\MySQL\.mylogin.cnf directory on Windows and $HOME/.mylogin.cnf on non-Windows systems. See Section 4.6.7, “mysql_config_editor — MySQL Configuration Utility”.如果未设置,则默认值在Windows上为%APPDATA%\MySQL\.mylogin.cnf目录,在非Windows系统上为$HOME/.mylogin.cnf。请参阅第4.6.7节,“mysql_config编辑器--mysql配置实用程序”

The MYSQL_TEST_TRACE_DEBUG and MYSQL_TEST_TRACE_CRASH variables control the test protocol trace client plugin, if MySQL is built with that plugin enabled. For more information, see Using the Test Protocol Trace Plugin.如果MYSQL是在启用了测试协议跟踪客户端插件的情况下构建的,则MYSQL_TEST_TRACE_DEBUGMYSQL_TEST_TRACE_CRASH变量控制该插件。有关更多信息,请参阅使用测试协议跟踪插件

The default UMASK and UMASK_DIR values are 0640 and 0750, respectively. 默认的UMASKUMASK_DIR值分别为06400750MySQL assumes that the value for UMASK or UMASK_DIR is in octal if it starts with a zero. For example, setting UMASK=0600 is equivalent to UMASK=384 because 0600 octal is 384 decimal.MySQL假设UMASKUMASK_DIR的值以零开头时为八进制。例如,设置UMASK=0600等于UMASK=384,因为0600八进制是384十进制。

The UMASK and UMASK_DIR variables, despite their names, are used as modes, not masks:UMASKUMASK_DIR变量,尽管它们的名字是,但被用作模式,而不是掩码:

See also Section B.3.3.1, “Problems with File Permissions”.另请参见第B.3.3.1节,“文件权限问题”

It may be necessary to set PKG_CONFIG_PATH if you use pkg-config for building MySQL programs. See Building C API Client Programs Using pkg-config.如果您使用pkg-config构建MySQL程序,可能需要设置PKG_CONFIG_PATH。请参阅使用pkg-config构建C API客户端程序