Wordpress mysql problem - Error establishing a database connection

Posted January 27, 2014 14k views
Hi there, I've recently got the $10/m package and I've got two sites running off the server. A static jekyll site, and a wordpress website. I had both running really nicely, however, this morning I found: Error establishing a database connection when visiting the wordpress site. I ran `free -m` to see how much memory I had left and I could see there was only like 96mb left. Can anyone help me figure out how it'd suddenly stop working and drain all the memory, and why, even after a restart I still can't access the site. What can I do to fix and avoid this problem in the future. Do you recommend a higher package to run a wordpress website? Thanks in advance

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
7 answers
I did run the mysqld and it worked:

sudo mysqld

I'm not so into it -- a friend helped me with that.
  • You should get a Nobel prize!
    I am not new user! I forgot to run the command & was fighting with my.cnf’s all possible issues! Yeah, actually both mariadb & mysql need a kick. Thanks a lot.

You need to add swap: How To Add Swap on Ubuntu 12.04. WordPress is also best optimized with Nginx and caching. So, it's advisable to check out (i) memcache; (ii) APC; (iii) varnish; and (iv) the W3 Total Cache plugin -- in addition to switching to Nginx.
by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
I already swapped but nothing has changed. Still got this error!
@Ibranhim, did you manage to fix it? we got the same problem here with an wordpress installation.. :/
@Tiago: Running mysqld manually isn't recommended. Use this command instead:
sudo service mysql start
i've solve the same problem with "rror establishing a database connection" ( Not Enough RAM ) by added Swap, tune SQL, Apache ...

Read this post for more detail :

I have the same problem and tried a number of suggestions, including upgrading to a 1GB droplet, adding a swap file etc.. same problem.

I ended up creating an account here , transferred a copy of my site and it cleared up the problem, improved the performance dramatically and provided us with 24/7 support. This is one of those things where you get what you pay for.