MySQL validate_password_policy 未知系统变量

MySQL validate_password_policy unknown system variable

我正在使用 MySQL 5.7.25,我想通过在 MySQL 命令中这样做来增加我的 MySQL 密码策略:

SET GLOBAL validate_password_policy=2;

但我总是得到一个错误:

ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'

我试图列出 validate_password 变量:

SHOW VARIABLES LIKE 'validate_password%'

但它总是return空集

发生此问题是因为 validate_password 插件默认 未激活 。您可以通过这些命令解决:

mysql> select plugin_name, plugin_status from information_schema.plugins where plugin_name like 'validate%';

空集(0.00 秒)

mysql> install plugin validate_password soname 'validate_password.so';

查询正常,0 行受影响(0.02 秒)

mysql> select plugin_name, plugin_status from information_schema.plugins where plugin_name like 'validate%';

最后,您将显示以下内容:

+-------------------+---------------+
| plugin_name       | plugin_status |
+-------------------+---------------+
| validate_password | ACTIVE        |
+-------------------+---------------+
1 row in set (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.00 sec). 

这个命令对我有用。我正在使用 MySQL 8.

SET GLOBAL validate_password.policy=LOW;

SET GLOBAL validate_password_policy=LOW;

用 validate_password_policy

替换 validate_password(dot)policy