mysql> SET GLOBAL default_password_lifetime = 90;
单个用户设定
为每个具体的用户账户单独设置特定的值
ALTER USER ‘test’@‘localhost‘ PASSWORD EXPIRE INTERVAL 30 DAY;
禁用密码过期:
ALTER USER ‘test‘@‘localhost‘ PASSWORD EXPIRE NEVER;
让用户使用默认的密码过期全局策略:
ALTER USER ‘test‘@‘localhost‘ PASSWORD EXPIRE DEFAULT;
设置用户密码过期
mysql> ALTER USER ‘test‘@‘localhost‘ PASSWORD EXPIRE;
查看用户是否过期
select user,host,password_expired,password_last_changed,password_lifetime from user;
password_expired:枚举值,设置用户密码是否过期的开关,默认为N。
password_last_changed:记录密码最近修改的时间
password_lifetime:设置密码的有效时间,天数
show create user test@‘localhost‘;
ALTER USER test@‘localhost‘ IDENTIFIED BY ‘password‘;