create user ‘root’@'%' identified by ‘password’; 

grant ALL PRIVILEGES on *.* to ‘root’@'%' with grant option;

flush privileges;

if error  have root@localhost

delete from mysql.user where user=‘root’;
flush privileges;
create user ‘root’@'%' identified by ‘password’;
grant ALL PRIVILEGES on *.* to ‘root’@'%' with grant option;

select user, host from user;
show grants for ‘root’@'%';

FLUSH PRIVILEGES;

=====restore root privileges=====

http://stackoverflow.com/questions/1709078/how-can-i-restore-the-mysql-root-user-s-full-privileges

UPDATE mysql.user SET Grant_priv=‘Y’, Super_priv=‘Y’ WHERE User=‘root’;

FLUSH PRIVILEGES;

create user ‘root’@‘localhost’ identified by ‘password’;

create user ‘root’@'%' identified by ‘password’;

GRANT ALL ON *.* TO ‘root’@‘localhost’;

GRANT ALL ON *.* TO ‘root’@'%';