8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

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

6.9 环境变量6.9 Environment Variables

本节列出了直接或间接由 MySQL 使用的环境变量。这些变量中的大多数也可以在本手册的其他地方找到。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 的行为是更可取的。请参阅 第 6.2.2.2 节,“使用选项文件”。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 6.2.2.2, “Using Option Files”.

变量Variable 说明Description
AUTHENTICATION_KERBEROS_CLIENT_LOGAUTHENTICATION_KERBEROS_CLIENT_LOG Kerberos 身份验证日志级别。Kerberos authentication logging level.
AUTHENTICATION_LDAP_CLIENT_LOGAUTHENTICATION_LDAP_CLIENT_LOG 客户端 LDAP 身份验证的日志记录级别。Client-side LDAP authentication logging level.
AUTHENTICATION_PAM_LOGAUTHENTICATION_PAM_LOG PAM 认证插件调试日志设置。PAM authentication plugin debug logging settings.
CC 您的 C 编译器名称(用于运行 CMake)。The name of your C compiler (for running CMake).
CXX 您的 C++ 编译器名称(用于运行 CMake)。The name of your C++ compiler (for running CMake).
CC 您的 C 编译器名称(用于运行 CMake)。The name of your C compiler (for running CMake).
DBI_USERDBI_USER Perl DBI 的默认用户名。The default user name for Perl DBI.
DBI_TRACEDBI_TRACE Perl DBI 的跟踪选项。Trace options for Perl DBI.
HOMEHOME mysql 历史文件的默认路径是 $HOME/.mysql_history。The default path for the mysql history file is $HOME/.mysql_history.
LD_RUN_PATHLD_RUN_PATH 用于指定 libmysqlclient.so 的位置。Used to specify the location of libmysqlclient.so.
LIBMYSQL_ENABLE_CLEARTEXT_PLUGINLIBMYSQL_ENABLE_CLEARTEXT_PLUGIN 启用 mysql_clear_password 认证插件;参见 第 8.4.1.4 节,“客户端明文可插拔认证”。Enable mysql_clear_password authentication plugin; see Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”.
LIBMYSQL_PLUGIN_DIRLIBMYSQL_PLUGIN_DIR 用于查找客户端插件的目录。Directory in which to look for client plugins.
LIBMYSQL_PLUGINSLIBMYSQL_PLUGINS 客户端插件预加载。Client plugins to preload.
MYSQL_DEBUG 调试时的调试跟踪选项。Debug trace options when debugging.
MYSQL_GROUP_SUFFIXMYSQL_GROUP_SUFFIX 选项组后缀值(例如指定 --defaults-group-suffix)。Option group suffix value (like specifying --defaults-group-suffix).
MYSQL_HISTFILE mysql 历史文件的路径。如果设置了此变量,其值将覆盖 $HOME/.mysql_history 的默认值。The path to the mysql history file. If this variable is set, its value overrides the default for $HOME/.mysql_history.
MYSQL_HISTIGNORE 指定 mysql 不应记录到 $HOME/.mysql_history 或者 syslog 的语句模式,如果提供了 --syslog。Patterns specifying statements that mysql should not log to $HOME/.mysql_history, or syslog if --syslog is given.
MYSQL_HOME 服务器特定的 my.cnf 文件所在目录的路径。The path to the directory in which the server-specific my.cnf file resides.
MYSQL_HOST 由 mysql 命令行客户端使用的默认主机名。The default host name used by the mysql command-line client.
MYSQL_PS1 在 mysql 命令行客户端中使用的命令提示符。The command prompt to use in the mysql command-line client.
MYSQL_PWD 连接到 mysqld 时的默认密码。使用此方法不安全。请参见表格后的注释。The default password when connecting to mysqld. Using this is insecure. See note following table.
MYSQL_TCP_PORT 默认的 TCP/IP 端口号。The default TCP/IP port number.
MYSQL_TEST_LOGIN_FILE .mylogin.cnf 登录路径文件的名称。The name of the .mylogin.cnf login path file.
MYSQL_TEST_TRACE_CRASH 测试协议跟踪插件是否会导致客户端崩溃。请参阅表格后的说明。Whether the test protocol trace plugin crashes clients. See note following table.
MYSQL_TEST_TRACE_DEBUG 测试协议跟踪插件是否生成输出。请参见表格后的说明。Whether the test protocol trace plugin produces output. See note following table.
MYSQL_UNIX_PORT 默认的 Unix 套接字文件名;用于连接 localhost。The default Unix socket file name; used for connections to localhost.
MYSQLX_TCP_PORT X 插件的默认 TCP/IP 端口号。The X Plugin default TCP/IP port number.
MYSQLX_UNIX_PORT X 插件的默认 Unix 套接字文件名;用于连接 localhost。The X Plugin default Unix socket file name; used for connections to localhost.
NOTIFY_SOCKET mysqld 用于与 systemd 通信的套接字。Socket used by mysqld to communicate with systemd.
PATHPATH 被 shell 用来查找 MySQL 程序。Used by the shell to find MySQL programs.
PKG_CONFIG_PATH mysqlclient.pc pkg-config 文件的位置。见表后注释。Location of mysqlclient.pc pkg-config file. See note following table.
TMPDIR 创建临时文件的目录。The directory in which temporary files are created.
TZ 这应该设置为您的本地时区。请参见 B.3.3.7 节,“时区问题”。This should be set to your local time zone. See Section B.3.3.7, “Time Zone Problems”.
UMASK 创建文件时的用户文件创建模式。见表格后的注释。The user-file creation mode when creating files. See note following table.
UMASK_DIR 创建目录时的用户目录创建模式。见表格后的注释。The user-directory creation mode when creating directories. See note following table.
USERUSER 在连接到 mysqld 时,Windows 的默认用户名。The default user name on Windows when connecting to mysqld.

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

使用 MYSQL_PWD 指定 MySQL 密码必须被认为是 极不安全的,不应使用。某些版本的 ps 包含显示正在运行进程的环境的选项。在某些系统上,如果你设置了 MYSQL_PWD,你的密码会暴露给运行 ps 的任何其他用户。即使在没有这种版本 ps 的系统上,也不应假设没有其他方法可以让用户查看进程环境。Use of MYSQL_PWD to specify a MySQL password must be considered extremely insecure and should not be used. Some versions of ps include an option to display the environment of running processes. 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.

MYSQL_PWD 从 MySQL 8.4 起已弃用;预计将在未来的 MySQL 版本中移除。MYSQL_PWD is deprecated as of MySQL 8.4; expect it to be removed in a future version of MySQL.

MYSQL_TEST_LOGIN_FILE 是登录路径文件的路径名(该文件由 mysql_config_editor 创建)。如果未设置,默认值为 Windows 系统上的 %APPDATA%\MySQL\.mylogin.cnf 目录,以及非 Windows 系统上的 $HOME/.mylogin.cnf。参见 第 6.6.7 节,“mysql_config_editor — MySQL 配置工具”。MYSQL_TEST_LOGIN_FILE is the path name of the login path file (the file created by 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 6.6.7, “mysql_config_editor — MySQL Configuration Utility”.

MYSQL_TEST_TRACE_DEBUG 和 MYSQL_TEST_TRACE_CRASH 变量控制测试协议跟踪客户端插件,如果 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.

默认的 UMASK 和 UMASK_DIR 值分别是 0640 和 0750。如果 UMASK 或 UMASK_DIR 的值以零开头,MySQL 假设该值为八进制。例如,设置 UMASK=0600 等同于 UMASK=384,因为八进制的 0600 等于十进制的 384。The default UMASK and UMASK_DIR values are 0640 and 0750, respectively. MySQL 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.

尽管名称如此,UMASK 和 UMASK_DIR 变量实际上用作模式,而不是掩码:The UMASK and UMASK_DIR variables, despite their names, are used as modes, not masks:

  • 如果设置了 UMASK,mysqld 会使用 ($UMASK | 0600) 作为文件创建模式,从而新创建的文件的模式在 0600 到 0666 范围内(所有数值为八进制)。If UMASK is set, mysqld uses ($UMASK | 0600) as the mode for file creation, so that newly created files have a mode in the range from 0600 to 0666 (all values octal).

  • 如果设置了UMASK_DIR,mysqld 使用 ($UMASK_DIR | 0700) 作为目录创建的基本模式,然后再与 ~(~$UMASK & 0666) 做 AND 运算,从而新创建的目录的模式在 0700 到 0777 之间(均为八进制值)。AND 运算可能会移除目录模式中的读写权限,但不会移除执行权限。If UMASK_DIR is set, mysqld uses ($UMASK_DIR | 0700) as the base mode for directory creation, which then is AND-ed with ~(~$UMASK & 0666), so that newly created directories have a mode in the range from 0700 to 0777 (all values octal). The AND operation may remove read and write permissions from the directory mode, but not execute permissions.

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

如果你在构建 MySQL 程序时使用 pkg-config,可能需要设置 PKG_CONFIG_PATH。请参阅 使用 pkg-config 构建 C API 客户端程序。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.