1、登录Mysql
sudo mysql -u root -p
2、查看user表(错误发生的原因就是root的plugin设置错误)
select user, plugin from mysql.user;
3、修改root的plugin为自己的密码
update mysql.user set authentication_string=PASSWORD('your passwd'), plugin='mysql_native_password' where user='root';
"your passwd" 字段为你想设置的密码"
4、刷新
flush privileges;