Error establishing a database connection ... MYSQL not running.

November 4, 2019 118 views
Apache WordPress Ubuntu

Hello there.

Two weeks ago I’ve already posted here, looking for help. The resolution I got can be found here.

I figured that the droplet I was using was the problem, so I moved on to another project, on another 1 click installation wordpress image.

The website worked fine for the last 4 days since I created it, reassuring me in my presumption that the first website’s droplet must’ve a problem.

However, about 2 hours ago, I received the error message “Error establishing a database connection” that led me here the first time.

Once again, the website itself is about 2gb large and uses a domain that was purchased 4 days ago. Since I have it linked to cloudways, I got a little curious.

Apparently my new domain received 15,595 from 43 unique users over the course of the last 4 days. I don’t have much knowledge in the ways of server management and while I don’t have caching enabled yet, something just seems super odd and I don’t believe that enabling SWAP as recommended in the linked thread is the solution here, given that my “free -h” response is

total: 985M used: 164M free: 617M

A quick # mysqladmin -u root -p status shwoed that my MYSQL is no longer running.

It also doesn’t appear to be a xmlrpc brute force since “sudo a2enconf block-xmlrpc” is already enabled.

2 Answers

Hello,

There are a few things that I could suggest:

  • In order to fix your current problem I believe that you just need to start your MySQL service:
systemctl start mysql

It most likely crashed due to out of memory problem. You should be able to see the error at:

/var/log/syslog
  • Check your access logs for any malicious activity, you could use this script here to summarize your access log:

https://github.com/bobbyiliev/quick_access_logs_summary

  • Consider adding a caching plugin like W3 total cache or WP super cache, that way you would reduce the number of requests to your SQL instance as some of your content would be served from static cache.

  • Consider increasing the available RAM for your Droplet

  • Consider using a CDN service

Hope that this helps! Let me know if you have any questions.
Regards,
Bobby

Hey, I have a similar issue, the thread is here - https://www.digitalocean.com/community/questions/one-click-install-wordpress-droplet-error-establishing-database-connection-returns

I dont get any issues in the logs, cannot find a reason for mysql spontaneously stopping to work and I am now resizing my droplet, though I am running a cache plugin for Wordpress, I have Cloudflare running for the domain and Wordpress install and my memory seems free and fine, currently and in the monitoring tools.

Have another answer? Share your knowledge.