MySQL远程连接报错:Host is not allowed to connect to this MySQL server

时间:2022-04-23 03:09:33

原文地址:http://chen3888015.blog.51cto.com/2693016/986841

在命令行连接MySQL时,不会报错,但是远程连接时,会报错:Host is not allowed to connect to this MySQL server

这个可能是因为你的账号不允许从远程登录,解决办法有两个:

1 改表法

运行命令如下:

1) mysql -uroot -proot

2) use mysql;

3) update user set host = '%' where user = 'root';

4) select host, user from user;

2 授权法

grant all privilieges on *.* to 'root'@'182.119.208.53' identified by 'yourpassword' with grant option

我当时试了第一种方法,依然报错,然后接着试了第二个方法,远程就能连上了。