ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
MySQL5.7为root用户随机生成了一个密码,在error log中,关于error log的位置,默认是/var/log/mysqld.log
获取随机密码:
grep “password” /var/log/mysqld.log
[root@instance-2lfpjykx ~]# mysql -uroot -p
输入随机密码登入mysql
修改用户密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'xxxxxx';
出现错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
这个与validate_password_policy的值有关,修改为一个简单的密码,会报以上错误。
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,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
不想密码设置得那么复杂,如只想设置root的密码为123456
设置
set global validate_password_policy=0;
现在密码只需符合长度限制
validate_password_length参数默认为8,它有最小值的限制,最小值为:
Length = validate_password_number_count+validate_password_special_char_count+ (2 * validate_password_mixed_case_count)
其中,validate_password_number_count指定了密码中数据的长度,validate_password_special_char_count指定了密码中特殊字符的长度,validate_password_mixed_case_count指定了密码中大小字母的长度。
这些参数,默认值均为1,所以validate_password_length最小值为4,如果你显性指定validate_password_length的值小于4,尽管不会报错,但validate_password_length的值将设为4。
mysql> set global validate_password_length = 6;
Query OK, 0 rows affected (0.00 sec)
mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
| 6 |
+----------------------------+