设置密码:
mysql> set password for root@localhost = password('test123');
报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
直译报错:您的密码不符合当前的政策要求(密码初始验证策略要求)
查看mysql初始密码验证策略:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| 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、validate_password_check_user_name:验证密码检查用户名,非必须
2、validate_password_dictionary_file:验证密码字典文件,无要求
3、 validate_password_length:验证密码长度,8字符
4、validate_password_mixed_case_count:验证密码混合大小写,否
5、validate_password_policy:验证密码策略,中等
6、validate_password_special_char_count:验证密码特殊字符数,否
报错其实与validate_password_policy的值有关,validate_password_policy有以下取值:
Policy
Tests Performe(要求)
0 or LOW
Length
1 or MEDIUM
numeric, lowercase/uppercase, and special characters
2 or STRONG
Length; numeric, lowercase/uppercase, and special characters
默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
解决办法:
简单2步即可解决,修改验证密码相关数据以支持简单密码设置:
mysql> set global validate_password_length=6;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set password for root@localhost = password('test123');
Query OK, 0 rows affected, 1 warning (0.01 sec)
设置密码成功。