1、忘记root密码,免密登录的方法见https://blog.csdn.net/q283614346/article/details/90732968
2、修改root密码
# 切换数据库
use mysql;
# 查看所有用户
select user,host from user;
# 修改密码
alter user 'root'@'%' identified with mysql_native_password by 'mysql';
# 刷新
flush privileges;