MySQL 提示 Your password does not satisfy the current policy requirements
这里写自定义目录标题
解决方案
mysql -uroot
mysql> 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.01 sec)
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.mixed_case_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.number_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.special_char_count=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password.length=3;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------+-------+
| validate_password_dictionary_file | |
| validate_password_length | 3 |
| validate_password_mixed_case_count | 0 |
| validate_password_number_count | 0 |
| validate_password_policy | LOW |
| validate_password_special_char_count | 0 |
+--------------------------------------+-------+
6 rows in set (0.00 sec)
mysql> SET PASSWORD FOR 'root'@'localhost' = '123';
Query OK, 0 rows affected (0.01 sec)
成功将密码设置为 123
,不过现在 MySQL 好像不可以直接用 root
当做密码。
问题原因
使用 brew install mysql
按照后,安装提示
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
你一定是不知所云的执行了 mysql_secure_installation
然后就莫名其妙的设置了密码安全级别。
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
密码检测参数介绍
validate_password.dictionary_file
插件用于验证密码强度的字典文件路径。
validate_password.length
密码最小长度,参数默认为8,它有最小值的限制,最小值为:validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
validate_password.mixed_case_count
密码至少要包含的小写字母个数和大写字母个数。
validate_password.number_count
密码至少要包含的数字个数。
validate_password.policy
密码强度检查等级,0/LOW、1/MEDIUM、2/STRONG。有以下取值:
Policy Tests Performed
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
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
validate_password.special_char_count
密码至少要包含的特殊字符数。