After doing my daily check up on my Webserver hosting a few websites (including this one) and multiple mySQL database, I found something was not right as all of the websites I host that used a database were seeing “Could Not Establish Connection To Database.” I Looked at the error logs and saw nothing, the file was clean, you would think having nothing in your error log is a good thing right? Well not in this case…
The message “Could Not Establish Connection To Database” is telling you that, well it can’t connect to the mySQL server, so make sure that it is running. After logging into the server I noticed that the mySQL server has stopped running, but why? Ok simple fix, I’ll just restart the mySQL server by issuing the command “start mysql.” No luck I was getting another error message “start: Job failed to start mysql,” ok but why? Ok I’ll check the error log again, maybe there is something in there now! Nope, error log is still blank.
After realizing how long the issue has been occurring (1 1/2 hours after 5 PM) I realize that 5PM is when the server does a complete database backup of everything, 5PM everyday. I go and check the folder of backups and see there is over 1 months worth of backups, all 190MBs or more. Although the server is backing up the databases as planned it’s also not deleting old database backups as it should be, because having a server backup everyday can eat your disk space quickly.
After deleting most of the backups I immediately reissued the “start mysql” command and finally everything started to work again.
TLDR: Make sure your servers have a lot of free disk space.