MySQL_password_policy

环境

MySQL Version: 5.7

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
mysql> show variables like '%plugin%';
+-------------------------------+--------------------------+
| Variable_name | Value |
+-------------------------------+--------------------------+
| default_authentication_plugin | mysql_native_password |
| plugin_dir | /usr/lib64/mysql/plugin/ |
+-------------------------------+--------------------------+
2 rows in set (0.02 sec)

mysql> select * from mysql.plugin;
+-------------------+----------------------+
| name | dl |
+-------------------+----------------------+
| validate_password | validate_password.so |
+-------------------+----------------------+
1 row in set (0.00 sec)

mysql> uninstall PLUGIN validate_password;
Query OK, 0 rows affected (0.01 sec)

mysql> select * from mysql.plugin;
Empty set (0.00 sec)

mysql> show variables like '%validate_password%';
Empty set (0.00 sec)

mysql> install PLUGIN validate_password SONAME 'validate_password.so';
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)

mysql>

查看密码策略

1
2
3
4
5
6
7
8
9
10
show variables like '%validate_password_policy%';
show variables like '%validate_password_length%';

[mysql version:8.X]
#查看密码策略
show variables like '%validate_password.policy%';
show variables like '%validate_password.length%';
#修改密码策略
set global validate_password.policy=0;
set global validate_password.length=1;

修改密码策略

1
2
set global validate_password_policy=0;
set global validate_password_length=1;
1
2
3
4
5
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

alter user 'root'@'localhost' identified by '123456789';

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements.