After mysql5.7.4
Set the global default password expiration time
Modify the my.cnf configuration file:
[mysqld]
default_password_lifetime=90 #密码90天过期
或是
[mysqld]
default_password_lifetime=0 #密码永不过期
Or modify at runtime:
SET GLOBAL default_password_lifetime = 90;
Set a user’s password expiration time
#密码90天过期:
ALTER USER ‘testuser’@‘localhost' PASSWORD EXPIRE INTERVAL 90 DAY;
#禁用密码过期
ALTER USER 'testuser'@'localhost' PASSWORD EXPIRE NEVER;
#让用户使用默认的密码过期全局策略:
ALTER USER 'testuser'@'localhost' PASSWORD EXPIRE DEFAULT;