首先将MySQL服务stop

systemctl stop mysqld

然后使用跳过密码启动MySQL:

mysqld --user=mysql --skip-grant-tables

修改mysql库下面的user这张表

update user set authentication——string=password('123') where user='root';