By yogaco
I am running a ready-made Wordpress droplet. Today my website displayed the dreaded “failed to establish database connection” message. I logged in to the server and noticed that the mysqld daemon doesn’t run in the background, so restarted it and all was fine again.
Question is, why would mysqld randomly stop by itself? I don’t want to find out that the WP website just doesn’t work when a potential client wants to look at it.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Yes, you should look at system logs before come to a conclusion. But there is a 95% chance that this happened due to lack of memory. You’ll have to upgrade your droplet if that’s the case. And while you’re at it you can create a more optimized environment for WordPress using a LEMP setup.
Every droplet I have ever created with an install of Wordpress will eventually crash MySQL, unless I take certain steps.
Mostly, what happens is that Wordpress is barraged with bots trying to login or gain access to your Wordpress account.
A few steps will diminish these attacks to rarely if ever crash MySQL:
Lastly, I created a script that will check on MySQL and Apache and restart them if needed:
https://github.com/sierracircle/services-checker
Those things will not completely stop all bots or attacks on your Wordpress site, but they will stop the mindless bots that are searching for basic/common installs of Wordpress, which will make MySQL crash.
For fun, once you install Login-Lockdown, wait for a bit and then view the logs (under settings in Wordpress) and you will see all of the attempts that have been made to access your site. You can see all of the common names and passwords that the bots use to try and login with.
What is your Droplet size? Are you using 512MB Droplet?
What comes to my mind is that if MySQL could got killed because it left without available RAM.
As of Ubuntu 16.04, default MySQL is 5.7, which requires at least 1GB of RAM on Droplet.
If you are really using 512MB Droplet I could recommend you upgrading to higher or setting-up swap
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.