第一步

mysql -u root -p ‘原来的密码’

第二步

use mysql;

第三步

CREATE USER 'root'@'%' IDENTIFIED BY '你的密码';
GRANT ALL ON *.* TO 'root'@'%';
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';

第四步

FLUSH PRIVILEGES;