Home » Php » php – MySQL server at 'reading initial communication packet', system error: 111

php – MySQL server at 'reading initial communication packet', system error: 111

Posted by: admin July 12, 2020 Leave a comment

Questions:

I moved my site to godaddy server, but the SQL connection is not working even with adequate changes which was working perfectly fine before

<?php
$link = mysql_connect('www.xxxxx.com', 'phpadminusername', 'phpadminpasswor');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
/*echo 'Connected successfully';*/
echo "DB CONNECTION :<font color='green'>ACTIVE</font>";


?>

It is showing an error

Warning: mysql_connect() [function.mysql-connect]: Lost connection to
MySQL server at ‘reading initial communication packet’, system error:
111 in /home/content/58/9508458/html/psychiatric/private.php on line
196 Could not connect: Lost connection to MySQL server at ‘reading
initial communication packet’, system error: 111

How to&Answers:

fixed by updating to hostname in account manager specifically given by godaddy.com .. not just the domain name

Answer:

That probably means mySQL is configured to only listed to requests from a particular hosts (or hosts). You can tell MySQL to only accept packets from particular IP addresses (usually localhost, but it may be wider on GoDaddy – not sure as I don’t use them).

Check your connection string – specifically the ‘www.xxxxx.com’ bit. This might need to be ‘localhost’ or a specific IP address.