当客户端连接到 MySQL 服务器时,服务器使用客户端提供的用户名和客户端主机来从mysql.user系统表中选择适当的账户行。然后,服务器对客户端进行认证,根据账户行确定哪个认证插件适用于客户端:When a client connects to the MySQL server, the server uses the
user name provided by the client and the client host to select the
appropriate account row from the mysql.user
system table. The server then authenticates the client,
determining from the account row which authentication plugin
applies to the client:
如果服务器找不到插件,将发生错误,并且连接尝试会被拒绝。If the server cannot find the plugin, an error occurs and the connection attempt is rejected.
否则,服务器会调用该插件来验证用户身份,插件会向服务器返回一个状态,指示用户是否提供了正确的密码并被允许连接。Otherwise, the server invokes that plugin to authenticate the user, and the plugin returns a status to the server indicating whether the user provided the correct password and is permitted to connect.
可插拔身份验证提供了以下重要功能:Pluggable authentication enables these important capabilities:
认证方法的选择。 可插拔认证使数据库管理员能够轻松选择和更改单个 MySQL 账户使用的认证方法。Choice of authentication methods. Pluggable authentication makes it easy for DBAs to choose and change the authentication method used for individual MySQL accounts.
外部认证。 可插拔认证使客户端能够使用适用于将凭据存储在
mysql.user系统表之外的认证方法的凭据连接到 MySQL 服务器。例如,可以创建插件以使用外部认证方法,如 PAM、Windows 登录 ID、LDAP 或 Kerberos。External authentication. Pluggable authentication makes it possible for clients to connect to the MySQL server with credentials appropriate for authentication methods that store credentials elsewhere than in themysql.usersystem table. For example, plugins can be created to use external authentication methods such as PAM, Windows login IDs, LDAP, or Kerberos.代理用户: 如果允许用户连接,认证插件可以向服务器返回一个与连接用户名称不同的用户名,以表示连接用户是另一个用户(被代理用户)的代理。在连接持续期间,代理用户在访问控制方面被视为具有被代理用户的权限。实际上,一个用户扮演另一个用户。更多信息请参见 第 8.2.19 节,“代理用户”。Proxy users: If a user is permitted to connect, an authentication plugin can return to the server a user name different from the name of the connecting user, to indicate that the connecting user is a proxy for another user (the proxied user). While the connection lasts, the proxy user is treated, for purposes of access control, as having the privileges of the proxied user. In effect, one user impersonates another. For more information, see Section 8.2.19, “Proxy Users”.
如果您使用 --skip-grant-tables 选项启动服务器,即使加载了身份验证插件,它们也不会被使用,因为服务器不执行客户端身份验证,并允许任何客户端连接。由于这不安全,如果使用 --skip-grant-tables 选项启动服务器,它还会通过启用 skip_networking 来禁用远程连接。If you start the server with the
--skip-grant-tables option,
authentication plugins are not used even if loaded because the
server performs no client authentication and permits any client
to connect. Because this is insecure, if the server is started
with the --skip-grant-tables
option, it also disables remote connections by enabling
skip_networking.
MySQL 8.4 提供这些身份验证插件:MySQL 8.4 provides these authentication plugins:
一个执行本地身份验证的插件;也就是说,基于在引入可插拔身份验证之前使用的密码散列方法的身份验证。
mysql_native_password插件基于这种本地密码散列方法实现身份验证。请参见 第 8.4.1.1 节,“本地可插拔身份验证”。A plugin that performs native authentication; that is, authentication based on the password hashing method in use from before the introduction of pluggable authentication in MySQL. Themysql_native_passwordplugin implements authentication based on this native password hashing method. See Section 8.4.1.1, “Native Pluggable Authentication”.Notemysql_native_password身份验证插件已被弃用,并可能在 MySQL 的未来版本中移除。Themysql_native_passwordauthentication plugin is deprecated and subject to removal in a future version of MySQL.使用 SHA-256 密码哈希进行身份验证的插件。这比本地身份验证可用的加密更强。请参阅 8.4.1.2 节,“缓存 SHA-2 可插拔身份验证”,以及 8.4.1.3 节,“SHA-256 可插拔身份验证”。Plugins that perform authentication using SHA-256 password hashing. This is stronger encryption than that available with native authentication. See Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”, and Section 8.4.1.3, “SHA-256 Pluggable Authentication”.
一个客户端插件,将密码发送到服务器时不进行哈希或加密。此插件与需要按客户端用户提供的原始密码访问的服务器端插件一起使用。请参阅 8.4.1.4 节,“客户端明文可插拔身份验证”。A client-side plugin that sends the password to the server without hashing or encryption. This plugin is used in conjunction with server-side plugins that require access to the password exactly as provided by the client user. See Section 8.4.1.4, “Client-Side Cleartext Pluggable Authentication”.
一个使用 PAM(可插入认证模块)执行外部认证的插件,使 MySQL 服务器能够使用 PAM 来认证 MySQL 用户。该插件也支持代理用户。参见 第 8.4.1.5 节,“PAM 可插入认证”。A plugin that performs external authentication using PAM (Pluggable Authentication Modules), enabling MySQL Server to use PAM to authenticate MySQL users. This plugin supports proxy users as well. See Section 8.4.1.5, “PAM Pluggable Authentication”.
一个在 Windows 上执行外部认证的插件,使 MySQL 服务器能够使用本地 Windows 服务来认证客户端连接。已登录 Windows 的用户可以根据其环境中的信息从 MySQL 客户端程序连接到服务器,而无需指定额外的密码。该插件也支持代理用户。参见 第 8.4.1.6 节,“Windows 可插入认证”。A plugin that performs external authentication on Windows, enabling MySQL Server to use native Windows services to authenticate client connections. Users who have logged in to Windows can connect from MySQL client programs to the server based on the information in their environment without specifying an additional password. This plugin supports proxy users as well. See Section 8.4.1.6, “Windows Pluggable Authentication”.
通过 LDAP(轻量目录访问协议)执行身份验证的插件,通过访问 X.500 等目录服务来验证 MySQL 用户。这些插件也支持代理用户。参见 第 8.4.1.7 节,“LDAP 可插拔身份验证”。Plugins that perform authentication using LDAP (Lightweight Directory Access Protocol) to authenticate MySQL users by accessing directory services such as X.500. These plugins support proxy users as well. See Section 8.4.1.7, “LDAP Pluggable Authentication”.
通过 Kerberos 执行身份验证的插件,用于验证与 Kerberos 主体对应的 MySQL 用户。参见 第 8.4.1.8 节,“Kerberos 可插拔身份验证”。A plugin that performs authentication using Kerberos to authenticate MySQL users that correspond to Kerberos principals. See Section 8.4.1.8, “Kerberos Pluggable Authentication”.
一个插件,它阻止所有客户端连接到使用它的任何账户。该插件的使用场景包括那些永远不允许直接登录但只能通过代理账户访问的代理账户,以及必须能够以提升权限执行存储程序和视图但不向普通用户暴露这些权限的账户。请参阅 第 8.4.1.9 节,“无登录可插拔认证”。A plugin that prevents all client connections to any account that uses it. Use cases for this plugin include proxied accounts that should never permit direct login but are accessed only through proxy accounts and accounts that must be able to execute stored programs and views with elevated privileges without exposing those privileges to ordinary users. See Section 8.4.1.9, “No-Login Pluggable Authentication”.
一个插件,它验证通过 Unix 套接字文件从本地主机连接的客户端。请参阅 第 8.4.1.10 节,“套接字对等凭证可插拔认证”。A plugin that authenticates clients that connect from the local host through the Unix socket file. See Section 8.4.1.10, “Socket Peer-Credential Pluggable Authentication”.
一个使用 FIDO/FIDO2 设备按 WebAuthn 格式对用户进行 MySQL 服务器认证的插件。请参见 第 8.4.1.11 节,“WebAuthn 可插拔认证”。A plugin that authenticates users to MySQL Server using WebAuthn format with a FIDO/FIDO2 device. See Section 8.4.1.11, “WebAuthn Pluggable Authentication”.
一个测试插件,用于检查账户凭证并将成功或失败记录到服务器错误日志中。该插件用于测试和开发目的,并作为编写认证插件的示例。请参见 第 8.4.1.12 节,“测试可插拔认证”。A test plugin that checks account credentials and logs success or failure to the server error log. This plugin is intended for testing and development purposes, and as an example of how to write an authentication plugin. See Section 8.4.1.12, “Test Pluggable Authentication”.
有关当前可插拔身份验证使用的限制信息,包括哪些连接器支持哪些插件,请参阅可插拔身份验证的限制。For information about current restrictions on the use of pluggable authentication, including which connectors support which plugins, see Restrictions on Pluggable Authentication.
第三方连接器开发人员应阅读该部分,以确定连接器在多插件认证功能上可以利用的程度,以及为提高兼容性需要采取的步骤。Third-party connector developers should read that section to determine the extent to which a connector can take advantage of pluggable authentication capabilities and what steps to take to become more compliant.
如果您有兴趣编写自己的认证插件,请参见 编写认证插件。If you are interested in writing your own authentication plugins, see Writing Authentication Plugins.
CREATE USER 和 ALTER USER 语句具有用于指定账户如何进行认证的语法。某些形式的此语法并未明确指定认证插件(没有 IDENTIFIED WITH 子句)。例如:The CREATE USER and
ALTER USER statements have syntax
for specifying how an account authenticates. Some forms of this
syntax do not explicitly name an authentication plugin (there is
no IDENTIFIED WITH clause). For example:
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'password';
在这种情况下,服务器会将默认身份验证插件分配给账户。MySQL 8.4 支持多因素身份验证,并且最多支持三条条款来指定账户如何进行身份验证。确定未指定插件的身份验证方法的默认身份验证插件的规则是针对具体因素的:In such cases, the server assigns the default authentication plugin to the account. MySQL 8.4 supports multifactor authentication and up to three clauses that specify how an account authenticates. The rules that determine the default authentication plugin for authentication methods that name no plugin are factor-specific:
因素 1:如果
authentication_policy的第 1 个元素指定了一个身份验证插件,则该插件为默认插件。如果authentication_policy的第 1 个元素为*,则caching_sha2_password为默认插件。Factor 1: Ifauthentication_policyelement 1 names an authentication plugin, that plugin is the default. Ifauthentication_policyelement 1 is*,caching_sha2_passwordis the default.根据上述规则,以下语句创建了一个双因素身份验证账户,其第一个因素的身份验证方法由
authentication_policy决定,如下所示:Given the rules above, the following statement creates a two-factor authentication account, with the first factor authentication method determined byauthentication_policy, as shown here:CREATE USER 'wei'@'localhost' IDENTIFIED BY '
password' AND IDENTIFIED WITH authentication_ldap_simple;以同样的方式,此示例创建了一个三因素认证账户:In the same way, this example creates a three-factor authentication account:
CREATE USER 'mateo'@'localhost' IDENTIFIED BY '
password' AND IDENTIFIED WITH authentication_ldap_simple AND IDENTIFIED WITH authentication_fido;您可以使用
SHOW CREATE USER来查看应用的身份验证方法。You can useSHOW CREATE USERto view the applied authentication methods.因素 2 或 3:如果相应的
authentication_policy元素指定了一个身份验证插件,则该插件为默认插件。如果authentication_policy元素为*或为空,则没有默认值;在没有指定插件的情况下尝试为该因素定义帐户身份验证方法将导致错误,如以下示例所示:Factor 2 or 3: If the correspondingauthentication_policyelement names an authentication plugin, that plugin is the default. If theauthentication_policyelement is*or empty, there is no default; attempting to define an account authentication method for the factor without naming a plugin is an error, as in the following examples:mysql>
CREATE USER 'sofia'@'localhost' IDENTIFIED WITH authentication_ldap_simpleAND IDENTIFIED BY 'abc';ERROR 1524 (HY000): Plugin '' is not loaded mysql>CREATE USER 'sofia'@'localhost' IDENTIFIED WITH authentication_ldap_simpleAND IDENTIFIED BY 'abc';ERROR 1524 (HY000): Plugin '*' is not loaded
本节提供有关安装和使用身份验证插件的一般说明。有关特定插件的说明,请参阅第 8.4.1 节,“身份验证插件”中描述该插件的部分。This section provides general instructions for installing and using authentication plugins. For instructions specific to a given plugin, see the section that describes that plugin under Section 8.4.1, “Authentication Plugins”.
一般来说,可插拔认证在服务器端和客户端使用一对对应的插件,因此您可以这样使用给定的认证方法:In general, pluggable authentication uses a pair of corresponding plugins on the server and client sides, so you use a given authentication method like this:
如果需要,安装包含适当插件的插件库。在服务器主机上,安装包含服务器端插件的库,以便服务器可以使用它来验证客户端连接。同样,在每个客户端主机上,安装包含客户端插件的库以供客户端程序使用。内置的认证插件无需安装。If necessary, install the plugin library or libraries containing the appropriate plugins. On the server host, install the library containing the server-side plugin, so that the server can use it to authenticate client connections. Similarly, on each client host, install the library containing the client-side plugin for use by client programs. Authentication plugins that are built in need not be installed.
对于您创建的每个 MySQL 帐户,请指定用于身份验证的适当服务器端插件。如果该帐户使用默认身份验证插件,则创建帐户的语句无需显式指定插件。服务器会分配默认的身份验证插件,如默认身份验证插件中所述。For each MySQL account that you create, specify the appropriate server-side plugin to use for authentication. If the account is to use the default authentication plugin, the account-creation statement need not specify the plugin explicitly. The server assigns the default authentication plugin, determined as described in The Default Authentication Plugin.
当客户端连接时,服务器端插件会告诉客户端程序应使用哪个客户端插件进行身份验证。When a client connects, the server-side plugin tells the client program which client-side plugin to use for authentication.
如果一个账户使用的身份验证方法是服务器和客户端程序的默认方法,则服务器无需向客户端传达应使用哪个客户端插件,从而可以避免一次客户端/服务器协商的往返。In the case that an account uses an authentication method that is the default for both the server and the client program, the server need not communicate to the client which client-side plugin to use, and a round trip in client/server negotiation can be avoided.
对于标准的 MySQL 客户端,例如 mysql 和 mysqladmin,可以在命令行中指定 --default-auth= 选项,作为程序期望使用哪种客户端插件的提示,尽管如果用户账户关联的服务器端插件需要不同的客户端插件,服务器端会覆盖此设置。For standard MySQL clients such as mysql and
mysqladmin, the
plugin_name--default-auth=
option can be specified on the command line as a hint about
which client-side plugin the program can expect to use, although
the server overrides this if the server-side plugin associated
with the user account requires a different client-side plugin.plugin_name
如果客户端程序找不到客户端插件库文件,请指定 --plugin-dir= 选项以指示插件库目录的位置。If the client program does not find the client-side plugin
library file, specify a
dir_name--plugin-dir=
option to indicate the plugin library directory location.dir_name
可插拔身份验证使 MySQL 账户在身份验证方法的选择上更具灵活性,但在某些情况下,由于客户端和服务器之间身份验证插件不兼容,客户端连接可能无法建立。Pluggable authentication enables flexibility in the choice of authentication methods for MySQL accounts, but in some cases client connections cannot be established due to authentication plugin incompatibility between the client and server.
成功的客户端连接到给定服务器上的特定账户的一般兼容性原则是,客户端和服务器都必须支持该账户所需的认证方法。由于认证方法是由认证插件实现的,因此客户端和服务器都必须支持该账户所需的认证插件。The general compatibility principle for a successful client connection to a given account on a given server is that the client and server both must support the authentication method required by the account. Because authentication methods are implemented by authentication plugins, the client and server both must support the authentication plugin required by the account.
身份验证插件的不兼容可能以各种方式出现。例如:Authentication plugin incompatibilities can arise in various ways. Examples:
使用 MySQL 5.7 客户端(版本 5.7.22 或更低)连接到使用
caching_sha2_password进行认证的 MySQL 8.4 服务器账户。这会失败,因为 5.7 客户端不识别该插件。(在 MySQL 5.7.23 中,这个问题得到了处理,当时在 MySQL 客户端库和客户端程序中添加了对caching_sha2_password的客户端支持。)Connect using a MySQL 5.7 client from 5.7.22 or lower to a MySQL 8.4 server account that authenticates withcaching_sha2_password. This fails because the 5.7 client does not recognize the plugin. (This issue is addressed in MySQL 5.7 as of 5.7.23, whencaching_sha2_passwordclient-side support was added to the MySQL client library and client programs.)使用 MySQL 5.7 客户端连接到使用
mysql_old_password进行认证的 5.7 之前的服务器账户。这会因为多种原因失败。首先,这种连接需要--secure-auth=0,而该选项已不再受支持。即使该选项仍被支持,5.7 客户端也不识别该插件,因为它在 MySQL 5.7 中已被移除。Connect using a MySQL 5.7 client to a pre-5.7 server account that authenticates withmysql_old_password. This fails for multiple reasons. First, such a connection requires--secure-auth=0, which is no longer a supported option. Even were it supported, the 5.7 client does not recognize the plugin because it was removed in MySQL 5.7.使用来自社区版的 MySQL 5.7 客户端连接到使用企业版专有 LDAP 认证插件进行认证的 MySQL 5.7 企业版服务器账户。这会失败,因为社区版客户端无法访问企业版插件。Connect using a MySQL 5.7 client from a Community distribution to a MySQL 5.7 Enterprise server account that authenticates using one of the Enterprise-only LDAP authentication plugins. This fails because the Community client does not have access to the Enterprise plugin.
通常,当客户端和服务器来自相同 MySQL 发行版时,不会出现这些兼容性问题。当客户端和服务器来自不同 MySQL 系列时,可能会出现问题。这些问题是 MySQL 在引入新的认证插件或移除旧插件的开发过程中固有的。为了尽量减少潜在的兼容性问题,应定期及时升级服务器、客户端和连接器。In general, these compatibility issues do not arise when connections are made between a client and server from the same MySQL distribution. When connections are made between a client and server from different MySQL series, issues can arise. These issues are inherent in the development process when MySQL introduces new authentication plugins or removes old ones. To minimize the potential for incompatibilities, regularly upgrade the server, clients, and connectors on a timely basis.
存在各种 MySQL 客户端/服务器协议的实现。libmysqlclient C API 客户端库就是一种实现。一些 MySQL 连接器(通常是非 C 语言编写的)提供了它们自己的实现。然而,并非所有协议实现都以相同的方式处理插件身份验证。本节描述了协议实现者应考虑的一种身份验证问题。Various implementations of the MySQL client/server protocol
exist. The libmysqlclient C API client
library is one implementation. Some MySQL connectors (typically
those not written in C) provide their own implementation.
However, not all protocol implementations handle plugin
authentication the same way. This section describes an
authentication issue that protocol implementors should take into
account.
在客户端/服务器协议中,服务器告诉连接的客户端它认为的默认认证插件。如果客户端使用的协议实现尝试加载默认插件,而该插件在客户端不存在,则加载操作会失败。如果默认插件并不是客户端尝试连接的账户实际上所需的插件,这就是一个不必要的失败。In the client/server protocol, the server tells connecting clients which authentication plugin it considers the default. If the protocol implementation used by the client tries to load the default plugin and that plugin does not exist on the client side, the load operation fails. This is an unnecessary failure if the default plugin is not the plugin actually required by the account to which the client is trying to connect.
如果客户端/服务器协议实现没有自己的默认认证插件概念,并且总是尝试加载服务器指定的默认插件,那么如果该插件不可用,就会出现错误。If a client/server protocol implementation does not have its own notion of default authentication plugin and always tries to load the default plugin specified by the server, it fails with an error if that plugin is not available.
为避免此问题,客户端使用的协议实现应有自己的默认插件,并应将其作为首选(或者,在无法加载服务器指定的默认插件时,备用使用此默认插件)。示例:To avoid this problem, the protocol implementation used by the client should have its own default plugin and should use it as its first choice (or, alternatively, fall back to this default in case of failure to load the default plugin specified by the server). Example:
在 MySQL 5.7 中,
libmysqlclient默认使用mysql_native_password或通过MYSQL_DEFAULT_AUTH选项在mysql_options()中指定的插件。In MySQL 5.7,libmysqlclientuses as its default choice eithermysql_native_passwordor the plugin specified through theMYSQL_DEFAULT_AUTHoption formysql_options().当 5.7 客户端尝试连接到 8.4 服务器时,服务器将
caching_sha2_password指定为默认认证插件,但客户端仍然会根据mysql_native_password或通过MYSQL_DEFAULT_AUTH指定的内容发送凭证信息。When a 5.7 client tries to connect to an 8.4 server, the server specifiescaching_sha2_passwordas its default authentication plugin, but the client still sends credential details per eithermysql_native_passwordor whatever is specified throughMYSQL_DEFAULT_AUTH.客户端唯一加载服务器指定的插件的情况是在换插件请求时,但在这种情况下,插件可以是任何插件,取决于用户账户。在这种情况下,客户端必须尝试加载该插件,如果该插件不可用,则错误不可避免。The only time the client loads the plugin specified by the server is for a change-plugin request, but in that case it can be any plugin depending on the user account. In this case, the client must try to load the plugin, and if that plugin is not available, an error is not optional.
本节的第一部分描述了可插拔身份验证框架的一般适用性限制,该框架在第 8.2.17 节,“可插拔身份验证”中有描述。第二部分描述了第三方连接器开发人员如何确定连接器能够利用可插拔身份验证功能的程度,以及采取哪些步骤以提高合规性。The first part of this section describes general restrictions on the applicability of the pluggable authentication framework described at Section 8.2.17, “Pluggable Authentication”. The second part describes how third-party connector developers can determine the extent to which a connector can take advantage of pluggable authentication capabilities and what steps to take to become more compliant.
此处使用的术语“本地认证”是指针对存储在mysql.user系统表中的密码进行认证。这与较早版本的 MySQL 服务器提供的认证方法相同,在可插拔认证实现之前使用。“Windows 本地认证”是指使用已登录 Windows 的用户凭据进行认证,这由 Windows 本地认证插件(简称“Windows 插件”)实现。The term “native authentication” used here refers
to authentication against passwords stored in the
mysql.user system table. This is the same
authentication method provided by older MySQL servers, before
pluggable authentication was implemented. “Windows native
authentication” refers to authentication using the
credentials of a user who has already logged in to Windows, as
implemented by the Windows Native Authentication plugin
(“Windows plugin” for short).
可插入式认证的一般限制General Pluggable Authentication Restrictions
Connector/C : 使用此连接器的客户端只能通过使用本地认证的账户连接到服务器。Connector/C++: Clients that use this connector can connect to the server only through accounts that use native authentication.
例外情况:如果连接器被构建为动态链接到
libmysqlclient(而非静态链接),并且如果安装了该版本,它会加载当前版本的libmysqlclient,或者如果连接器从源代码重新编译以链接到当前的libmysqlclient,则该连接器支持可插入式认证。Exception: A connector supports pluggable authentication if it was built to link tolibmysqlclientdynamically (rather than statically) and it loads the current version oflibmysqlclientif that version is installed, or if the connector is recompiled from source to link against the currentlibmysqlclient.有关编写连接器以处理来自服务器的默认服务器端身份验证插件信息的详细信息,请参阅 身份验证插件连接器编写考虑事项。For information about writing connectors to handle information from the server about the default server-side authentication plugin, see Authentication Plugin Connector-Writing Considerations.
Connector/NET: 使用 Connector/NET 的客户端可以通过使用本地身份验证或 Windows 本地身份验证的帐户连接到服务器。Connector/NET: Clients that use Connector/NET can connect to the server through accounts that use native authentication or Windows native authentication.
Connector/PHP: 使用此连接器的客户端仅能通过使用本地身份验证的帐户连接到服务器,当使用 PHP 的 MySQL 本地驱动程序(
mysqlnd)编译时。Connector/PHP: Clients that use this connector can connect to the server only through accounts that use native authentication, when compiled using the MySQL native driver for PHP (mysqlnd).Windows 本地认证: 通过使用 Windows 插件的账户连接需要进行 Windows 域设置。如果没有设置,则使用 NTLM 认证,并且只能进行本地连接;也就是说,客户端和服务器必须运行在同一台计算机上。Windows native authentication: Connecting through an account that uses the Windows plugin requires Windows Domain setup. Without it, NTLM authentication is used and then only local connections are possible; that is, the client and server must run on the same computer.
代理用户: 代理用户支持在客户端能够通过使用实现代理用户功能的插件进行身份验证的账户连接时提供(即,能够返回与连接用户不同的用户名的插件)。例如,PAM 和 Windows 插件支持代理用户。
mysql_native_password(已弃用)和sha256_password(已弃用)身份验证插件默认不支持代理用户,但可以配置为支持;参见 代理用户映射服务器支持。Proxy users: Proxy user support is available to the extent that clients can connect through accounts authenticated with plugins that implement proxy user capability (that is, plugins that can return a user name different from that of the connecting user). For example, the PAM and Windows plugins support proxy users. Themysql_native_password(deprecated) andsha256_password(deprecated) authentication plugins do not support proxy users by default, but can be configured to do so; see Server Support for Proxy User Mapping.复制:副本不仅可以使用本地认证的复制用户账户进行复制,还可以在具备所需客户端插件的情况下,通过使用非本地认证的复制用户账户进行连接。如果插件已内置于
libmysqlclient中,则默认可用。否则,插件必须安装在副本端,安装目录为副本的plugin_dir系统变量指定的目录。Replication: Replicas can not only employ replication user accounts using native authentication, but can also connect through replication user accounts that use nonnative authentication if the required client-side plugin is available. If the plugin is built intolibmysqlclient, it is available by default. Otherwise, the plugin must be installed on the replica side in the directory named by the replica'splugin_dirsystem variable.FEDERATED表:FEDERATED表只能通过远程服务器上使用本地认证的账户访问远程表。FEDERATEDtables: AFEDERATEDtable can access the remote table only through accounts on the remote server that use native authentication.
可插拔认证与第三方连接器Pluggable Authentication and Third-Party Connectors
第三方连接器开发人员可以使用以下指南来确定连接器是否准备好利用可插拔身份验证功能,以及采取哪些步骤以提高合规性:Third-party connector developers can use the following guidelines to determine readiness of a connector to take advantage of pluggable authentication capabilities and what steps to take to become more compliant:
一个未经过任何修改的现有连接器使用本地认证,并且使用该连接器的客户端只能通过使用本地认证的账户连接到服务器。但是,你应该针对服务器的最新版本测试该连接器,以验证这种连接仍然能够正常工作。An existing connector to which no changes have been made uses native authentication and clients that use the connector can connect to the server only through accounts that use native authentication. However, you should test the connector against a recent version of the server to verify that such connections still work without problem.
例外情况:如果连接器动态(而非静态)链接到
libmysqlclient,并且在安装了该版本时加载当前版本的libmysqlclient,那么它可能在不做任何修改的情况下可以与可插拔认证一起工作。Exception: A connector might work with pluggable authentication without any changes if it links tolibmysqlclientdynamically (rather than statically) and it loads the current version oflibmysqlclientif that version is installed.为了利用可插拔身份验证功能,基于
libmysqlclient的连接器应重新链接到当前版本的libmysqlclient。这使连接器能够支持通过需要客户端插件的帐户连接,这些插件现在内置于libmysqlclient中(例如 PAM 身份验证所需的明文插件和 Windows 本机身份验证所需的 Windows 插件)。与当前libmysqlclient链接还使连接器能够访问安装在默认 MySQL 插件目录中的客户端插件(通常为本地服务器的plugin_dir系统变量默认值所指定的目录)。To take advantage of pluggable authentication capabilities, a connector that islibmysqlclient-based should be relinked against the current version oflibmysqlclient. This enables the connector to support connections though accounts that require client-side plugins now built intolibmysqlclient(such as the cleartext plugin needed for PAM authentication and the Windows plugin needed for Windows native authentication). Linking with a currentlibmysqlclientalso enables the connector to access client-side plugins installed in the default MySQL plugin directory (typically the directory named by the default value of the local server'splugin_dirsystem variable).如果连接器动态地链接到
libmysqlclient,必须确保在客户端主机上安装了更新版本的libmysqlclient,并且连接器在运行时加载它。If a connector links tolibmysqlclientdynamically, it must be ensured that the newer version oflibmysqlclientis installed on the client host and that the connector loads it at runtime.连接器支持给定身份验证方法的另一种方式是在客户端/服务器协议中直接实现它。Connector/NET 使用这种方法来提供对 Windows 本地身份验证的支持。Another way for a connector to support a given authentication method is to implement it directly in the client/server protocol. Connector/NET uses this approach to provide support for Windows native authentication.
如果一个连接器能够从不同于默认插件目录的目录加载客户端插件,它必须实现某种方式让客户端用户指定该目录。这种方式的可能性包括命令行选项或环境变量,通过它连接器可以获取目录名称。标准的 MySQL 客户端程序,例如 mysql 和 mysqladmin 实现了一个
--plugin-dir选项。另请参见 C API 客户端插件接口。If a connector should be able to load client-side plugins from a directory different from the default plugin directory, it must implement some means for client users to specify the directory. Possibilities for this include a command-line option or environment variable from which the connector can obtain the directory name. Standard MySQL client programs such as mysql and mysqladmin implement a--plugin-diroption. See also C API Client Plugin Interface.如本节前面所述,连接器对代理用户的支持取决于其支持的身份验证方法是否允许代理用户。Proxy user support by a connector depends, as described earlier in this section, on whether the authentication methods that it supports permit proxy users.