dongxu7121 2012-07-11 15:02
浏览 50
已采纳

MySQL远程访问麻烦?

I have a database set up on a godaddy server. It is configured to allow remote access, and there are a couple of websites I'm running which need to access this data. It works when accessed from another godaddy site, and I can connect from my development environment both at work and home. We recently set up hosting with mydomain.com.

Here is the code block that triggered it:

function connect(){
    $servername = "XX.XX.XXX.XX";
    $dbusername = "databaseusername";
    $dbpassword = "mahpassword";
    $dbname = "databasename";
    try{
      $newMysql = new PDO("mysql:host=".$servername.";dbname=".$dbname, $dbusername, $dbpassword);
    }
        catch(PDOException $e){
        echo 'connection Failed: '. $e->getMessage();
        die;
    }
}

and now I'm getting this error message on the new site:

connection Failed: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'XX.XX.XXX.XX' (111)

The only problems I can think of is that either for some reason there are a limited number of IP addresses the MySQL database will connect to by default (which seems squirrely), I'm getting blocked by a firewall on the MySQL server (again.. doesn't make sense to me), or there is some setting on the mydomain hosting server disallowing remote requests (?)

I'm new to this kind of thing, so I'm open to any suggestions. I could probably just set up another database on the new site, but I don't want the hassle of keeping them synchronized if I don't need to. What might be wrong? Are there any workarounds?

[edit] connected to remote database via console (mysql -h XX.XX.XXX.XX ...), the privileges were found under the information_schema database, a quick select * from SCHEMA_PRIVILEGES and select * from USER_PRIVILEGES shows that 'databaseusername'@'%' has sufficient privileges. Not that it helped me any, but maybe it'll help someone down the road. [/edit]

  • 写回答

1条回答 默认 最新

  • doubi4814 2014-01-26 21:51
    关注

    As it has been more than a year since I asked this question, I suppose I need to answer it just to close it.

    It turns out that godaddy had blocked mydomain.com servers via firewall ("Remote access" was limited). so in order to accomplish what I wanted to do, I had to copy and store the database on both sites.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 三爪夹具,在重物的影响下,三爪受力怎么分析?能把三个爪当成螺栓吗?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目