After publishing a post, my website displays Error Establishing Database Connection

December 26, 2013 3.4k views
Hi, followed the instructions on here to install Wordpress on Ubuntu 12.04. However whenever I publish a post my site goes down and I'm left with an Error Establishing Database Connection message. I can get rid of it by typing 'sudo server mysql restart' in putty, but having to do this after every post is getting rather tedious. Has anybody encountered this before, or know of a way in which I can fix? Cheers
7 Answers
"Has anybody encountered this before..."

Lots of folks. This is a very common occurrence for users running Apache on WordPress Installations. The better alternative is Nginx. See How To Install Wordpress, Nginx, PHP, and Varnish on Ubuntu 12.04 and/or How To Migrate from an Apache Web Server to Nginx on an Ubuntu VPS
by Etel Sverdlov
Varnish is an HTTP accelerator and a useful tool for speeding up a server, especially during a times when there is high traffic to a site. It works by redirecting visitors to static pages whenever possible and only drawing on the server itself if there is a need for an active process. This tutorial covers installing wordpress on a LEMP stack (with nginx instead of apache), and then installing varnish.
I am using nginx and I'm still getting this issue. I also followed the swap tutorial. I can't even access Wordpress at all.
@Dillon,

Have you tried rebooting your droplet?
I finally got it working. It was a simple password error.

When doing this:
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");

and this:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';

make sure the "password" strings on both lines are the same. I made the mistake of only putting my secure password in the first command and not the second. I re-ran the commands with the passwords in both commands and it's working now.
If you're interested in optimizing your WordPress site, check out 10 Million hits a day with WordPress using a $15 server (but notice that the author of that blog post now uses a $10/mo. DigitalOcean VPS).

Im also facing the same problem with my WordPress blog. Whenever i publish or update the article it shows Database error, the same time this error occurs to our site users. I don't know how to solve this error please someone help me out. My site: http://techindroid.com/

Have another answer? Share your knowledge.