MySQL high memory usage (error establishing a database connection)

September 27, 2015 1.9k views

I'm facing the high memory issue usage which leads to killing of MySQL. I've to use this command to get my site back up

service mysql start

Also i ran some memory tests by type free and i saw my free memory was around 98m and decreasing. I've 1gb droplet and my traffic is not much, 2000+ UVs daily.

The buffer cache also showed my i've around 90 mb free memory.

Update : Restarted the server and now it seems good for far, but a permanent fix would be nice.

2 Answers

If your MySQL process is running out of memory you may want to create a swap file. This tutorial will guide you in this process. Aside from this, you can investigate additional ways to optimize your configuration or upgrade to a larger droplet to ensure enough memory is available for your processes.

by Justin Ellingwood
Swap space can be used as an "overflow" area for your system when you run out of RAM. The operating system can store data that would normally be kept in RAM on the hard drive in a specially formatted file. In this guide, we'll demonstrate how to create and use one of these files in Ubuntu 14.04.

I had the same issue, with a 2GB droplet size. Tried everything and eventually discovered it was an XML-RPC attack (Wordpress related).

Check this article for help:
How To Protect WordPress from XML-RPC Attacks on Ubuntu 14.04

WordPress is a popular and powerful CMS (content management system) platform. Its popularity can bring unwanted attention in the form of malicious traffic specially targeted at a WordPress site. There are many instances where a server that has not been protected or optimized could experience issues or errors after receiving a small amount of malicious traffic. This guide will show you how to protect WordPress from XML-RPC attacks on an Ubuntu 14.04 system.
Have another answer? Share your knowledge.