mysql5.7的初始化后密码找回

1 通过日志文件中给出的默认密码 grep password /var/log/mysqld.log
2 日志文件发生意外后,vim /etc/my.cnf 添加skip-grant-tables=1 或者skip-grant-tables 保存后重启数据库服务
mysql -uroot 即可进入数据库服务了
连接mysql库 use mysql;
更新user表中的root用户密码 update user set authentication_string=password(‘wang1.1’) where user=‘root’;
flush privileges;
后退出 删除my.cnf中添加的 skip-grant-tables 即完成密码的更换

alter user ‘root’@‘localhost’ identified by ‘新密码’;
密码简单格式
mysql> set global validate_password_policy=0;
set global validate_password_length=1; 原始的8位改成1位

猜你喜欢

转载自blog.csdn.net/weixin_43945743/article/details/85133240