MySQL8.0 修改密码

1、修改mysql配置,并重启:
在my.cnf 文件中添加skip-grant-tables
重启mysql:systemctl restart mysqld
2、直接mysql 登录,此时不需要填写密码。
3、清空root用户密码:
update mysql.user set authentication_string='' where user='root';
4、修改mysql配置,并重启:
在my.cnf 文件中注释掉skip-grant-tables,重启mysql:systemctl restart mysqld;
5、mysql -uroot 无密码登录到root模式。
6、查看root用户:
select user,host from user where user='root';
7、更新root密码:
alter user 'root'@'localhost' identified by 'new_password';
8、刷新权限:
flush privileges;

原文链接:https://blog.csdn.net/huryer/article/details/106957990

原文地址:https://www.cnblogs.com/JackShi/p/14890804.html