报错:2003 - cant connect ro mysql server on 'x.x.x.x'
解决方法如下:
本文远程连接的ubuntu下的数据库,原因是ubuntu系统的mysql不允许被远程连接操作
因此需要修改mysql配置文件
步骤:(1)cd /etc/mysql
(2)vim my.cnf
(3)将bind-address = 127.0.0.1修改为bind-address = 0.0.0.0
(4)保存退出
(5)/etc/init.d/mysql restart (一定要重启数据库,不然没用)
ok,此时就可以远程连接此数据库了
报错:1130 - Host 'x.x.x.x' is not allowed to connect to this MySQL server
解决办法参考:https://blog.csdn.net/h985161183/article/details/82218710
1.在安装Mysql数据库的主机上登录root用户:
mysql -u root -p
2.依次执行如下命令:
use mysq;
select host from user where user='root';
可以看到当前主机配置信息为localhost.
3.执行update user set host = '%' where user ='root'将Host设置为通配符%。
Host设置了“%”后便可以允许远程访问。
4.Host修改完成后记得执行flush privilegs使配置立即生效。