本地无法连接远程服务器(Host is not allowed to connect to this MySQL server)解决办法

问题描述:

1、远程服务器安装了mysql服务并且启动成功,在本地可以进行自由的访问和更新等操作
2、服务器已开通了远程访问服务器3306端口的权限并且通过netstat -ltnp命令查看3306处于监听过程中
3、远程通过工具链接该mysql数据库会报Host ‘xxx.xxx.xxx.xxx’(本地ip) is not allowed to connect to this MySQL server 的错误

解决办法:

1、远程链接服务器,在服务器内mysql系统目录下的/bin文件下执行./mysql -u root -p;输入密码登入mysql;
2、在mysql中执行use mysql命令,进入系统数据库
3、在mysql数据库中执行 select host from user where user = ‘root’;如果返回结果如下图:
该返回值表明root用户限制在当前主机环境下访问
该结果表示是由于当前的root用户限制在当前的内网ip内访问的,需要修改他的访问域。
4、在mysql数据库中执行 update user set host = ‘%’ where user = ‘root’;
5、执行完成后通过命令 service mysql restart 来重启mysql数据库,也可以在本地服务重新启动MySQL。

猜你喜欢

转载自blog.csdn.net/Youning_Yim/article/details/109351077