Error establishing a database connection Amazon EC2 - after moving my wordpress blog
For me just restarting the mysqld service worked. There was a hitch though, as soon as I executed sudo service mysqld restart
the MySql service stopped but didn't start. sudo services mysqld start
gave a MySQL Deamon Failed to Start Error. I spent a lot of time trying to start the service but I guess the real culprit was the httpd service. I stopped the httpd service sudo service httpd stop
. Now execute sudo service mysqld restart
and bingo the wordpress site was back online(remember to start the httpd service). This sounds kind of lame but it worked, from what I figured out the MySQL DB stops for a number of reasons looking at the log and figuring out the actual reason is the only thing that works for me.
Increase ur swap memory in ec2 that solves the problem. http://digitizor.com/2011/02/06/create-swap-file-ubuntu-linux/
I got the same error for my website, I just rebooted my instance and voila, problem solved.
My case:
I am using amazon free tier, and some bot requested my website and due to the high number of connections, the sql database could not serve the load. I have hence installed the load balancer too :) Hope it helps