MySQL server has gone away – where has it gone?

For reasons best left alone at this stage, I operate a Windows 2003 Server and have chosen to install PHP and MySQL on it so I can use WordPress. Together with an ISAPI Filter, I can do everything on there that you can do on an Apache Server (more or less). The trouble is… well, the trouble is Microsoft really. Whenever something goes wrong you’re on your own looking for why, and end up trawling through forums and websites where everyone pretty much says the same thing… why have you installed PHP and MySQL on a Windows Server?

The latest Microsoft-astrphe came when all of the WordPress sites went down, with the error message of ‘cannot establish database connection’. Upon attempting to access PHP MyAdmin, I found that too had failed and I couldn’t login to any of the databases. The error message spat out here was:

#2002 Cannot log in to the MySQL server

Oh dear.

This website offered some useful advice on checking whether the connection to MySQL was working or not. After following their advice I found that, in fact, it wasn’t. The reason given for this was, rather distressingly, outputted as:

“MySQL server has gone away”

This is indeed a worrying message. After searching online for solutions, this website proved helpful. But where has the MySQL server gone? Where are the databases? And we have now lost all of them?

I then tried to use the Microsoft Web Platform Installer to see if it could create a new WP install, and a new MySQL database. After following all the usual steps, it failed. The excuse given included the line:

“an existing connection was forcibly closed by the remote host”

I then upgraded the version of PHP on the server, hoping that would have an effect. It didn’t. Looking at websites that talked about editing the php.ini file, or editing files within PHP MyAdmin also proved unhelpful.

Finally, the solution presented itself. Due to the stupid way that Windows Servers tend to be partitioned, and the fact that the MySQL, SQL, Logfiles and various other important stuff resides on the C Drive, the space on the drive had reduced to such a degree that the MySQL Server had decided enough was enough, and it was off. This may sound stupid, or simplistic, but that was indeed the case.

After a few moments deleting as many Logfiles as I could afford to lose the MySQL Database reappeared, as if by magic, and all of the sites worked once again. So, if you are also running PHP and MySQL on a Windows Server and you’ve found that, suddenly, your website cannot connect to the database, before you go foraging around on forums and attempting to upgrade PHP or meddle with the php.ini file, just free up some space.

Darren Jamieson

Darren Jamieson, aka MrDaz, is the Technical Director and co-founder of Engage Web and has been working online in a career spanning two decades. His first website was built in 1998 and is still live today.

Facebook Twitter LinkedIn Google+ 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.