0

我越来越

Lost connection to MySQL server at 'reading initial communication packet', system error: 2

我要连接我的数据库时出错。

如果我使用 localhost 一切正常。但是,当我使用如下所示的实时 IP 地址时,出现错误:

mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());

请帮我。谢谢。

4

2 回答 2

0

为什么不只使用本地主机?

尝试不使用端口号。

或者

请检查您的服务器配置以及您使用的端口。

于 2013-07-31T10:27:53.387 回答
0

You can try following things:

  1. Make sure your Live IP is open to public requests
  2. Port is working fine. Usually MySQL use 3306
  3. Another way to check port is working or not is to use it with localhost
  4. The user you are using has object(db) access
  5. Try using root user credentials (but only for testing strictly)
  6. If its connecting with root credentials then create two separate users my_user@localhost and my_user@% and grand object access
于 2013-07-31T10:32:38.500 回答