忘记mysql的密码
第一步:修改/etc/my.cnf文件,在[mysqld]加入以下内容
skip-grant-tables
第二步:重启mysql服务
systemctl restart mysqld
第三步:免密登录
mysql -uroot
第四步:修改密码
update user set password=password('123456') where User='root';
第五步:删除第一步加入的skip-grant-tables
,重启mysql服务
如果新设置密码不符合规范,执行以下SQL:
set global validate_password_policy=LOW; #把密码复杂程度要求改成无要求
set global validate_password_length=6; #把密码长度要求改为6位