Error Lost connection to MySQL server at reading initial communication packet system

732    Asked by BenButler in Python , Asked on Jul 24, 2021

When I try to connect to the database I'm ending getting this error:

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

And when I am using my live IP address like below, it's getting error:

mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error())
Answered by Claudine Tippins

Lost connection to MySQL server at 'reading initial communication packet' There seems to be a problem with the firewall blocking outside connection.


 To resolve this error you have to follow the below steps:

bind-address = "YOUR MACHINE IP" in my.cnf file at /etc/my.cnf

Restart service by command : service httpd restart

GRANT ALL PRIVILEGES ON yourDB.* TO 'username'@'YOUR_APPLICATION_IP' IDENTIFIED BY 'YPUR_PASSWORD' WITH GRANT OPTION;

Hope this works!!



Your Answer

Interviews

Parent Categories