打开mysql客户端,直接运行以下命令:
1.use mysql;
2.update user set host='%' where user='root';
会报错:ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY',直接忽略!
3.flush privileges;
4.grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;(注:123456换成自定义的登录密码)
5.flush privileges;
重启下mysql服务,ok!