如何在配置文件设置mysql 8的密码验证插件参数

在测试环境中,密码验证插件这个功能挺烦的,不方便设置简单密码,于是尝试想将其关闭。

在网上查到都很多资料都是设置 validate_password这个参数,但是这个参数设置后,mysql就启动不了了,不知道是不是mysql 8这个版本使这个参数无效了。

[mysqld]
validate_password=OFF

日志文件里面错误大致是这样:

2023-03-19T04:00:34.319399Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-03-19T04:00:34.319443Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-03-19T04:00:34.322680Z 0 [ERROR] [MY-000067] [Server] unknown variable 'validate-password=OFF'.
2023-03-19T04:00:34.322779Z 0 [ERROR] [MY-010119] [Server] Aborting

直接在mysql里面用set设置validate_password参数,也是失败:

mysql> set global validate_password=OFF;
ERROR 1193 (HY000): Unknown system variable 'validate_password'

查看了一下mysql的参数:

mysql> show variables like 'validate%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| 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)

确实没有validate_password这个参数,只有validate_password.check_user_name,validate_password.policy这样的参数。看样子密码验证策略没法关闭了,只能考虑将其调低,在配置文件中加入如下参数:

validate_password.policy = 0
validate_password.length = 1

重启mysql后,查看参数:

mysql> show variables like 'validate%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)

发现length被设置为了4,这个参数最小值是4。validate_password.policy值已经设置为LOW。

你可能感兴趣的:(紫云的程序人生,SQL,mysql,ubuntu,数据库)