1、先用localhost方式连接到MySQL数据库,然后使用MySQL自带的数据库mysql;
use mysql;
2、执行:select host from user where user = ‘root’; 发现,host的值就是localhost。
所以将它的值改掉:update user set host=’%’ where user = ‘root’;
3、修改完成后,执行:flush privileges;
将修改内容生效,再次配置时,用IP地址或者localhost 就都能正常连接到MySQL数据库了
转载自:https://blog.csdn.net/recallect/article/details/79865323