登录mysql mysql -u root -p 或 mysql
use mysql;
// mysql 5.7
update user set authentication_string=PASSWORD("密码") where user='root';
// mysql8 以上
ALTER USER '你的用户名默认root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';
update user set plugin="mysql_native_password";
flush privileges;
quit;
/etc/init.d/mysql restart;
mysql -u root -p 密码;