MySQL如何解决root用户无法远程登录问题

715 阅读1分钟

问题:

SQL Error (1130): Host '12.4.8.10' is not allowed to connect to this MySQL server

这个问题是因为root账号没有远程登录的权限,只能在本地(localhost)登录。

我们需要将mysql自带的user表里的host字段值从 localhost 改称 %

在mysql本地登陆mysql

mysql -u root -p

输入root用户的密码。

登录成功后,分别执行如下命令:

use mysql;
​
update user set host='%' where user='root';
​
flush privileges;
​
select `host`,`userfrom user where user='root';
​
quit

然后root用户就可以在远程登录了。