6.2.19 Account Locking帐户锁定

MySQL supports locking and unlocking user accounts using the ACCOUNT LOCK and ACCOUNT UNLOCK clauses for the CREATE USER and ALTER USER statements:MySQL支持使用CREATE USERALTER USER语句的ACCOUNT LOCKACCOUNT UNLOCK子句锁定和解锁用户帐户:

Account locking state is recorded in the account_locked column of the mysql.user system table. 帐户锁定状态记录在mysql.user系统表的account_locked列中。The output from SHOW CREATE USER indicates whether an account is locked or unlocked.SHOW CREATE USER的输出指示帐户是锁定还是解锁。

If a client attempts to connect to a locked account, the attempt fails. 如果客户端尝试连接到锁定的帐户,则尝试失败。The server increments the Locked_connects status variable that indicates the number of attempts to connect to a locked account, returns an ER_ACCOUNT_HAS_BEEN_LOCKED error, and writes a message to the error log:服务器递增Locked_connects状态变量,该变量指示连接到锁定帐户的尝试次数,返回ER_ACCOUNT_HAS_BEEN_LOCKED错误,并将消息写入错误日志:

Access denied for user 'user_name'@'host_name'.
Account is locked.

Locking an account does not affect being able to connect using a proxy user that assumes the identity of the locked account. 锁定帐户不会影响使用假定锁定帐户身份的代理用户进行连接。It also does not affect the ability to execute stored programs or views that have a DEFINER attribute naming the locked account. That is, the ability to use a proxied account or stored programs or views is not affected by locking the account.它也不会影响执行具有命名锁定帐户的DEFINER属性的存储程序或视图的能力。也就是说,锁定帐户不会影响使用代理帐户或存储程序或视图的能力。

The account-locking capability depends on the presence of the account_locked column in the mysql.user system table.帐户锁定功能取决于mysql.user系统表中是否存在account_locked列。 For upgrades from MySQL versions older than 5.7.6, perform the MySQL upgrade procedure to ensure that this column exists. 对于从5.7.6之前的MySQL版本升级,请执行MySQL升级过程以确保此列存在。See Section 2.11, “Upgrading MySQL”. 请参阅第2.11节,“升级MySQL”For nonupgraded installations that have no account_locked column, the server treats all accounts as unlocked, and using the ACCOUNT LOCK or ACCOUNT UNLOCK clauses produces an error.对于没有account_locked列的未升级安装,服务器将所有帐户视为已解锁,使用ACCOUNT LOCKACCOUNT UNLOCK子句会产生错误。