问题描述:
在设置MySQL密码时报ERROR 1809错误ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决方法:
这是因为MySQL有密码设置的规范,具体是与validate_password_policy的值有关:
MySQL完整的初始密码规则可以通过如下命令查看:mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_check_user_name | OFF |
| 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 |
+--------------------------------------+-------+
rows in set (0.01 sec)
密码的长度是由validate_password_length决定的,而validate_password_length的计算公式是:validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
解决方法就是修改密码为规范复杂的密码:mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'z?guwrBhH7p>';
Query OK, 0 rows affected (0.00 sec)
这时候我们要把密码规则改一下,执行下面sql就可以了:mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql>
设置之后就是我上面查出来的那几个值了,此时密码就可以设置的很简单,例如1234之类的。到此数据库的密码设置就完成了。