MySQL设置⽤户密码过期策略
1.在MySQL运⾏时可以使⽤超级权限修改此配置:
mysql> SET GLOBAL default_password_lifetime = 90;
Query OK, 0 rows affected (0.00 c)
还可以使⽤ALTER USER命令为每个具体的⽤户账户单独设置特定的值,它会⾃动覆盖密码过期的全局策略。要注意ALTER USER语句的INTERVAL的单位是“天”。
ALTER USER ‘testur’@‘localhost' PASSWORD EXPIRE INTERVAL 30 DAY;
#配置⽂件
[mysqld]
default_password_lifetime=90
or
#命令⾏全局修改
指令英文
mysql> SET GLOBAL default_password_lifetime = 90;
Query OK, 0 rows affected (0.00 c)
mysql>
mysql> show variables like "default_password_lifetime";
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| default_password_lifetime | 90 |
+---------------------------+-------+recommend是什么意思
cancelled2.设置单个密码可重复使⽤时间和可重复使⽤的间隔次数
-- 设置密码为每间隔5次才可以重复使⽤
butterfly valve
mysql> create ur yeyz3@'127.0.0.1' identified with 'mysql_native_password' by 'yeyz3' password history 5;orchid
Query OK, 0 rows affected (0.01 c)
-- 设置密码为每隔5天才可以重复使⽤
mysql> create ur yeyz4@'127.0.0.1' identified with 'mysql_native_password' by 'yeyz4' password reu interval 5 day;
Query OK, 0 rows affected (0.01 c)
-- 设置密码为每隔5天可以重复使⽤或者每个5次才可以重复使⽤,取最严格的那个条件
mysql> create ur yeyz5@'127.0.0.1' identified with 'mysql_native_password' by 'yeyz5' password reu interval 5 day password history 5;
Query OK, 0 rows affected (0.01 c)
-- 使⽤默认的全局密码可重复使⽤策略,也就是password history参数和password reu interval参数
mysql> create ur yeyz6@'127.0.0.1' identified with 'mysql_native_password' by 'yeyz6' password reu interval default password history default;
Query OK, 0 rows affected (0.01 c)
3.让⽤户使⽤默认的密码过期全局策略:
ALTER USER 'testur'@'localhost' PASSWORD EXPIRE DEFAULT;
4.全局设定
mysql> SET GLOBAL default_password_lifetime = 90;
单个⽤户设定
lawbreakers
personalcenter为每个具体的⽤户账户单独设置特定的值
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;
查看⽤户是否过期
lect ur,host,password_expired,password_last_changed,password_lifetime from ur; password_expired:枚举值,设置⽤户密码是否过期的开关,默认为N。
password_last_changed:记录密码最近修改的时间
password_lifetime:设置密码的有效时间,天数
picshow create ur [email protected]‘localhost‘;
ALTER USER [email protected]‘localhost‘ IDENTIFIED BY ‘password‘;