MySQL connection lost: system error: 110

I try 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 did not configure a firewall, so all ports must be open. What do I need to do? I already checked several other similar questions, but none of them solved my problem. I am not connecting remotely .

UPDATE

Ok, I found a problem connecting to the server (I connected twice). I can connect to the server now, but when I run any request, the server returns FALSE. I used this code before, and it worked before, but now that I have changed the servers, it does not work.

Thanks,

David

+4
source share
2 answers

Maybe you are connecting to your db with different parameters.

+3
source

I had a similar error code "110" on server A. Never changed credentials, etc. on both servers A and B. However, my problem was that one server is actually communicating via the MySQL port: 3306 of server B, and I recently installed a firewall on server B to allow remote access to MySQL from server A. Server A tried connect to port 3306 of the MySQL server B, and the web server simply dragged out the time by issuing a MySQL error code and a line error to the code.

Solution that worked for me:
sudo ufw status

Check if there is a MySQL port in the list if it is not:
sudo ufw allows mysql

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

Good luck

0
source

Source: https://habr.com/ru/post/1437922/


All Articles