有两种方法:
一、
1、mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
2、mysql>FLUSH PRIVILEGES;
二、
1、mysql>use mysql;
2、mysql>update user set host='%' where user='root' AND host='localhost';
3、mysql>FLUSH PRIVILEGES;