当修改mysql密码时,如果密码设置的太简单的话,会提示报错:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+--------+ | Variable_name | Value | +--------------------------------------+--------+ | validate_password_check_user_name | OFF | 决定是否使用该插件(及强制/永久强制使用):ON/OFF/FORCE/FORCE_PLUS_PERMANENT | validate_password_dictionary_file | | 插件用于验证密码强度的字典文件路径 | validate_password_length | 8 | 密码最小长度 | validate_password_mixed_case_count | 1 | 密码至少要包含的小写字母个数和大写字母个数 | validate_password_number_count | 1 | 密码至少要包含的数字个数 | validate_password_policy | MEDIUM | 密码强度检查等级,0/LOW、1/MEDIUM、2/STRONG | validate_password_special_char_count | 1 | 密码至少要包含的特殊字符数 +--------------------------------------+--------+ 7 rows in set (0.02 sec) 0/LOW:只检查长度。 1/MEDIUM:检查长度、数字、大小写、特殊字符。 2/STRONG:检查长度、数字、大小写、特殊字符字典文件。
思路:
1、遵从策略
2、修改策略
3、策略失效
如输入的密码为:Wxq3012@
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Wxq3012@'; Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_policy=0; Query OK, 0 rows affected (0.00 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '12345678'; Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
[root@localhost ~]# systemctl restart mysqld
mysql> SHOW VARIABLES LIKE 'validate_password%';
my.cnf文件在所在目录:/etc/my.cnf
[root@localhost ~]# vim /etc/my.cnf ... ... validate_password_policy=0
[root@localhost ~]# systemctl restart mysqld
mysql> SHOW VARIABLES LIKE 'validate_password%';
[root@localhost ~]# vim /etc/my.cnf ... ... validate-password=OFF
[root@localhost ~]# systemctl restart mysqld
mysql> SHOW VARIABLES LIKE 'validate_password%';
mysql> uninstall plugin validate_password;