MySQL Variables default_password_lifetime 数据库 参数变量解释及正确配置使用

本站中文解释

default_password_lifetime参数设置的是MySQL的账号的密码的有效期,单位是天数。它可以设置成0,表示不限制。它也可以被设置成一个正整数,表示这个密码有效期为这么多天。超出这个期限,MySQL会提醒用户重设密码。

要设置default_password_lifetime,我们需要在my.cnf或者my.ini文件中添加如下参数:

default_password_lifetime = 30

将30替换成所需要的有效期天数即可。

官方英文解释

default_password_lifetime

Command-Line Format --default-password-lifetime=#
System Variable default_password_lifetime
Scope Global
Dynamic Yes
Type Integer
Default Value (≥ 5.7.11) 0
Default Value (≤ 5.7.10) 360
Minimum Value 0
Maximum Value 65535
Unit days

This variable defines the global automatic password expiration
policy. The default
default_password_lifetime
value is 0, which disables automatic password expiration. If
the value of
default_password_lifetime is
a positive integer N, it indicates
the permitted password lifetime; passwords must be changed
every N days.

The global password expiration policy can be overridden as
desired for individual accounts using the password expiration
options of the ALTER USER
statement. See Section 6.2.11, “Password Management”.

Note

Prior to MySQL 5.7.11, the default
default_password_lifetime
value is 360 (passwords must be changed approximately once
per year). For those versions, be aware that, if you make no
changes to the
default_password_lifetime
variable or to individual user accounts, all user passwords
expire after 360 days, and all user accounts start running
in restricted mode when this happens. Clients (which are
effectively users) connecting to the server then get an
error indicating that the password must be changed:
ERROR 1820 (HY000): You must reset your password
using ALTER USER statement before executing this
statement.

However, this is easy to miss for clients that automatically
connect to the server, such as connections made from
scripts. To avoid having such clients suddenly stop working
due to a password expiring, make sure to change the password
expiration settings for those clients, like this:

ALTER USER 'script'@'localhost' PASSWORD EXPIRE NEVER;

Alternatively, set the
default_password_lifetime
variable to 0, thus disabling automatic
password expiration for all users.


数据运维技术 » MySQL Variables default_password_lifetime 数据库 参数变量解释及正确配置使用