MySQL connection lost: system error: 110

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

I am trying to connect to my mySQL server through localhost on my dedicated server, but I keep getting the error:

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

CODE:

<?php  $link = mysql_connect('localhost', '****', '****');  if (!$link) {      die('Could not connect: ' . mysql_error());  }  

I haven't configured a firewall, so all ports should be open. What do I need to do? I have already checked several other similar questions, but none of them solved my problem. I am not connecting remotely.

UPDATE

Okay I found the issue with the connection to the server (I was connecting twice). I am able to connect now to the server, but when I run any query, the server returns FALSE. I have used this code before and it has worked before, but now that I have changed servers, it is not working.

Thanks,

David

回答1:

May be you are connecting to your db with different parameters



回答2:

I had a similar error code of "110" on server A. Have never changed the credentials, etc on both server A and B. However, my issue was that one server is actually communicating via the MySQL port: 3306 of server B, and I have recently setup firewall on server B, to allow remote MySQL access from server A. Server A was trying to connect to the Server B MySQL port 3306 and webserver would just timeout, issuing the MySQL error code and line error on the code.

Solution that worked for me is:
sudo ufw status

Check if MySQL port is in the list, if not do this:
sudo ufw allow mysql

This will add the ip4 and ip6 rules into the firewall approved list.

Good luck!



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!