简体   繁体   English

无法连接到远程主机上的mysql数据库

[英]Cannot connect to mysql database on remote host

I am not sure if the terms I am using are correct so ask for clarification if you need :). 我不确定我所使用的术语是否正确,因此请在需要时进行澄清:)。

Anyways, I am hosting through HostEasySolutions (Server A). 无论如何,我通过HostEasySolutions(服务器A)托管。 It comes with a MySql database, using PHPMyAdmin as the frontend. 它带有一个MySql数据库,使用PHPMyAdmin作为前端。 On Server A, I added some PHP files to access the database, and it works fine. 在服务器A上,我添加了一些PHP文件来访问数据库,并且工作正常。

If I copy the php files to my other server, through DreamHost (Server B), I cannot connect to the database. 如果我通过DreamHost(服务器B)将php文件复制到其他服务器,则无法连接到数据库。 I get the error: Can't connect to MySQL server on 'combinedsystems.ca' (110) 我收到错误消息: Can't connect to MySQL server on 'combinedsystems.ca' (110)

In the cPanel on Server A, I added the IP for Server B into the Remote Database Access Hosts, I also just added the wildcard '%', just to see if I could get it working...but still it can't find the server. 在服务器A上的cPanel中,我将服务器B的IP添加到了远程数据库访问主机中,我也刚刚添加了通配符'%',只是看我是否可以使它工作...但仍然找不到服务器。

I am not sure what is going on, as far as I can see there is no firewall. 据我所知没有防火墙,我不确定发生了什么。

The only thing that stands out to me, is that if I go to PHPmyAdmin for Server A, it says Server: Localhost via UNIX socket , where as for Server B's PHPMyAdmin, it says: Server: mysql.pdem.info via TCP/IP 对我而言,唯一与众不同的是,如果我去服务器A的PHPmyAdmin,它说的是Server: Localhost via UNIX socket ,而对于服务器B的PHPMyAdmin则说: Server: mysql.pdem.info via TCP/IP

Most (all?) hosting companies have port 3306 closed on the firewall. 大多数(所有?)托管公司的防火墙上的端口3306均已关闭。

What you need to do: 你需要做什么:

  • adding remote database access in the database 在数据库中添加远程数据库访问
  • edit my.cnf to listen on all interfaces. 编辑my.cnf以侦听所有接口。 Default mysql listens only to localhost 默认mysql仅侦听localhost

most of the time you are out of luck! 大多数时候,您不走运! Even if there is no firewall (would be very unsecure) you have no access to my.cnf 即使没有防火墙(会非常不安全),您也无法访问my.cnf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM