How To Fix Error Establishing Database On A WordPress Site

How To Fix Error Establishing Database On A WordPress Site

At some point you may try to login to a WordPress website and just get a page which says Error Establishing a Database Connection. That could be any number of things but here are two simple things you can do to fix this error.

1) Turn on MySQL
If you don’t have access to ssh into the site then you will have to ask your hosting company to turn it on for you. But if you have access then login to ssh, and type sudo start mysql and hit enter and that will turn on MySQL.

2) Install Wordfence plugin
Once you can login to your WordPress site then install the Wordfence plugin and run through the tutorial to ensure it is setup properly. The free version is fine for a website, and it blocks all sorts of attacks happening on your website.

Why does this happen?

There are a number of big reasons why this happens, MySQL runs out of memory and sometimes it happens on the biggest of sites and there is not very much you can do. The other reason why could be because people are attacking your site, there is not much you can do about that other than installing Wordfence or getting DDOS protection (which can run from free to very expensive options).


Gregory is the owner of Gregory J Development and he loves helping people with their websites. In his spare time, Gregory listens to music, writes (not just for the blog here), and is trying to read more often.