mysql5.7密码问题

时间:2024-12-02 14:04:08

安装:

yum search mysql

"""
mysql-server mysql mysql-devel
mysql-community-server
"""

自定义yum安装mysql在配置文件中定义,再启动

密码:

the first passwd in : /var/log/mysqld.log 

(A temporary password is generated for root@localhost: 8:4SK(U9br6.)

your must be change passwd for first:
mysql>
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

大小写字母、数字和特殊符号,并且长度不能少于8位。
否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误
mysql> alter user 'root'@'localhost' identified by 'E.....';

mysql.user库中:password字段改成了authentication_string
update mysql.user set authentication_string=password('123456') where user='root' ;

mysql官网密码策略介绍:
http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy

#(出现报错:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements)

#原因:mysql5.7 加强了密码的强度

mysql> show variables like "%password%";
+---------------------------------------+--------+
| Variable_name | Value |
+---------------------------------------+--------+
| default_password_lifetime | 0 |
| disconnect_on_expired_password | ON |
| log_builtin_as_identified_by_password | OFF |
| mysql_native_password_proxy_users | OFF |
| old_passwords | 0 |
| report_password | |
| sha256_password_proxy_users | OFF |
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | | 密码策略文件 (策略为STRONG时才需要)
| 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 | 特殊字符最少个数
+---------------------------------------+--------+
14 rows in set (0.01 sec)

更改密码的强度:
1、
set global validate_password_policy=0;
2、
my.cnf中设置:
validate_password = off #关闭密码策略