mysql -u root -p
mysql> use mysql;
mysql> select user,host from user;
mysql> update user set host='%' where user='root';
mysql> flush privileges;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql> flush privileges;