解决方法:
改表法
更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
update user set host = '%' where user = 'root';
flush privileges;
授权法
GRANT ALL PRIVILEGES ON *.* TO 'xxx.xxx.xxx.xxx' @'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
推荐方法
mysql -h localhost -u root
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION / /赋予任何主机访问数据的权限
FLUSH PRIVILEGES //修改生效
EXIT //退出MySQL服务器