MySQL在MySQL-5.7中有一个新变量,用于保存mysql用户的密码到期详细信息 - 在特定用户密码过期的几天之后。
此变量的详细信息:Doc
当我们更改此变量时,是否需要运行刷新权限,或者更改是否会立即对所有具有默认过期策略的用户生效?
答案 0 :(得分:0)
我认为答案是肯定的。
因为default_password_lifetime是一个全局变量,这些信息存储在information_schema.GLOBAL_VARAIBLES中,它是一个内存引擎表!
在mysql中,flush操作会导致缓冲区中的数据写回磁盘,只有在MyISAM引擎中才需要;但是,flush privileges子句会将磁盘MyISAM文件中的数据重新加载到内存中。 ;特权相关表。
答案 1 :(得分:0)
根据文件,没有必要:
6.3.6 Password Expiration Policy
...
当客户端成功连接时,服务器确定是否成功 帐户密码已过期:
服务器检查密码是否已手动过期,如果是,则限制会话。
否则,服务器会根据自动密码过期策略检查密码是否超过其生命周期。如果是这样, 服务器认为密码已过期并限制会话。
...
重要提示:此更改仅对后续连接生效。
这是一个例子:
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.18
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT @@GLOBAL.default_password_lifetime;
+------------------------------------+
| @@GLOBAL.default_password_lifetime |
+------------------------------------+
| 0 |
+------------------------------------+
1 row in set (0.00 sec)
mysql> CREATE USER 'johndoe'@'localhost'
-> IDENTIFIED WITH mysql_native_password AS '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'
-> PASSWORD EXPIRE DEFAULT;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
$ mysql -u johndoe -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.7.18
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT CURRENT_USER();
+-------------------+
| CURRENT_USER() |
+-------------------+
| johndoe@localhost |
+-------------------+
1 row in set (0.00 sec)
mysql> exit
Bye
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.18
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SET @@GLOBAL.default_password_lifetime := 1;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT @@GLOBAL.default_password_lifetime;
+------------------------------------+
| @@GLOBAL.default_password_lifetime |
+------------------------------------+
| 1 |
+------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT NOW();
+---------------------+
| NOW() |
+---------------------+
| 2010-01-01 00:00:01 |
+---------------------+
1 row in set (0.00 sec)
mysql> \! date -s "2010-01-02 $(date +%H:%M:%S)"
Sat Jan 02 00:00:05 UTC 2010
mysql> SELECT NOW();
+---------------------+
| NOW() |
+---------------------+
| 2010-01-02 00:00:06 |
+---------------------+
1 row in set (0.01 sec)
mysql> exit
Bye
$ mysql -u johndoe -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.7.18
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT CURRENT_USER();
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
其他感兴趣的信息: