MySQL设置密码复杂度

MySQL5.6.6版本之后增加了密码强度验证插件validate_password,相关参数设置的较为严格。使用了该插件会检查设置的密码是否符合当前设置的强度规则,若不满足则拒绝设置。

本文采用测试环境:MySQL 8.0.15

1、在 MySQL安装目录中,\MySQL Server 8.0\lib\plugin 可以看到默认存在validate_password.dll

MySQL设置密码复杂度

2、在MySQL 8.0.15中默认没有安装这个插件,我们可以通过  SELECT * from mysql.`plugin` 查看,列表为空。

安装插件:

添加:
  mysql> INSTALL PLUGIN validate_password SONAME 'validate_password.dll'; 卸载:
  mysql> UNINSTALL PLUGIN validate_password;

插件安装后,使用 show plugins; 查看是否启用成功

MySQL设置密码复杂度

3、查看默认策略配置:

show variables like 'validate_password%'; 

MySQL设置密码复杂度

4、测试

修改密码

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

提示错误

[SQL]alter user 'root'@'localhost' identified by '';
[Err] - Your password does not satisfy the current policy requirements

各项值说明

validate_password_policy:密码安全策略,默认MEDIUM策略

策略 检查规则
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

validate_password_dictionary_file:密码策略文件,策略为STRONG才需要

validate_password_length:密码最少长度

validate_password_mixed_case_count:大小写字符长度,至少1个

validate_password_number_count :数字至少1个  validate_password_special_char_count:特殊字符至少1个

修改策略(将策略要求置为LOW,长度要求置为1)

set global validate_password_policy=0;
set global validate_password_length=1;

MySQL设置密码复杂度

经测试,最小长度为4,设置为1无效,不晓得为什么,后面再查询下。

如不需要,可关闭复杂性策略:

mysql> set global validate_password_policy=;       # 关闭密码复杂性策略
mysql> set global validate_password_length=; # 设置密码复杂性要求密码最低长度为1
mysql> select @@validate_password_policy; # 查看密码复杂性策略
mysql> select @@validate_password_length; # 查看密码复杂性要求密码最低长度大小

重置密码验证,可成功修改:

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

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAe4AAAAxCAIAAACTat1PAAAHT0l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5mXu9N+a48e2RdrGuWlWtNDbldOfKT8tXcuVZler1vlx5xw6Woo9EyeSy00aCxX+9sJ0r7/iVFeB7EdsrjiVs427Px0M5T3x+t0yN52Fcdl+qJ34zdzKokjIVm2dCkp8LxUK/IedoZL5dxOfKbctL8XPIH6vX92euHSz+feWi20XJeK9N+2svCvYYBE8O/xWDu7hNrs9Pskx+J9+ab/5WvQGGuTR6YQYBAHw1M3dmAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5PwD2pDiJ15pwAcAAAAASUVORK5CYII=" alt="" />

密码重置成功,可重新登录。

参考链接:

https://www.cnblogs.com/zhi-leaf/p/5994478.html

上一篇:HttpClient官方sample代码的深入分析(连接池)


下一篇:WAMP中的mysql设置密码(默认密码为空)及phpmyadmin的配置