- 查看临时密码:
[root@god ~]# grep password /var/log/mysqld.log
2020-09-11T10:58:46.152697Z 1 [Note] A temporary password is generated for root@localhost: p(-Jp)6d!4RW
- 登录mysql(复制刚才的临时密码)
[root@xuegod69 ~]# mysql -uroot -p
Enter password:
- 修改mysql密码策略
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=3;
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=6;
Query OK, 0 rows affected (0.00 sec)
- 修改mysql密码
mysql> SET PASSWORD FOR root@localhost=PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
- 参数修改说明
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。