值得注意的是,在 MySQL 8.0 中,validate_password 插件被重新实现为 validate_password 组件。 validate_password 插件已弃用;预计它会在 MySQL 的未来版本中被删除。
相关参数更名为以 validate_password.* 前缀。
1 2 3 4 5 6 7 8 9 10 11 12 13
(root@localhost) [(none)]> show variables like 'validate_password%'; +--------------------------------------+--------+ | 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)
基于上述参数,我们在修改用户密码时需要注意密码的健壮性,可以通过下面这个函数来检查。
1 2 3 4 5 6 7
(root@localhost) [(none)]> SELECT VALIDATE_PASSWORD_STRENGTH('ShawnYan@CN_MYSQL8!'); +---------------------------------------------------+ | VALIDATE_PASSWORD_STRENGTH('ShawnYan@CN_MYSQL8!') | +---------------------------------------------------+ | 100 | +---------------------------------------------------+ 1 row in set (0.00 sec)
修改 root 密码
只是,在开发环境中,为了便于测试,我们可以临时将 root 密码改为空。
这里,将密码校验组件包改名,并重启 MySQL,检验功能会失效,但不影响 Server 正常启动。
1 2 3
cd /usr/lib64/mysql/plugin/ mv component_validate_password.so component_validate_password.so.bak systemctl restart mysqld
1 2
2023-06-11T16:23:49.575004Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001126 - Can't open shared library '/usr/lib64/mysql/plugin/component_validate_password.so' (errno: 0 /usr/lib64/mysql/plugin/component_validate_password.so: cannot open shared object file: No such file or directory) 2023-06-11T16:23:49.575088Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003529 - Cannot load component from specified URN: 'file://component_validate_password'.