ERROR 1130 (HY000): Host ‘ip‘ is not allowed to connect to this MariaDB server

远程连接mysql服务器报错,端口和iptables规则都没问题的情况下,需要对myslq服务器远程连接权限进行设置。

1.授权法
grant all privileges on *.* to 'user'@'%' identified by 'password' with grant option;
flush privileges;
%表示从任何主机连接到mysql服务器

或者

grant all privileges on *.* to 'user'@'192.168.0.60' identified by 'password' with grant option;
flush privileges;
表示从指定ip从任何主机连接到mysql服务器

 

 

2.该表法

可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入MySQL后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root'  and host='localhost';
mysql>select host, user from user;
mysql>flush privileges;

上面的set host= '%'   %可以改成指定的IP地址

ERROR 1130 (HY000): Host ‘ip‘ is not allowed to connect to this MariaDB server