CentOS下MySQL8.0的超详细的安装及配置文档( 二 )

密码恢复有时候,会将root密码给忘记了,就需要对MySQL进行密码恢复 。
在/etc/my.cnf中,的[mysqld]内,加入如下内容:
skip-grant-table//改为安全模式,无法密码登陆重启mysqld
systemctl restart mysqld进入重置密码
mysql -u root -p//空密码,直接回车use mysql;update user set authentication_string='' where user='root';//先清空密码注释掉my.cnf中的skip-grant-table,再重启mysqld 。然后就可以免密码进入,再修改密码 。
mysql -u root -p//不用输入密码,直接进入alter user 'root'@'localhost' identified with mysql_native_password by '三种或以上的八位字符';//修改密码,并将密码插件更改为mysql_native_password现在就恢复正常使用了 。




推荐阅读