I am running a VPS with 1024 mb ram that is hosting a single WordPress site. Lately I have been having a lot of database problems where WordPress is giving me "Error establishing a database connection". I can make the server crash just by crawling it with Screaming Frog SEO tool.

Sometimes the issue resolves itself, sometimes I need to manually restart MySQL, and other times I have to completely reboot the server.

I thought the error was related to MySQL itself, but after examining the various logs, it seems like my server is running out of memory and therefore simply killing MySQL.

Using MySqltuner, I am getting the following results:

[--] Physical Memory     : 992.6M
[--] Max MySQL memory    : 804.0M
[--] Other process memory: 306.2M
[--] Total buffers: 225.0M global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 409M
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 643.1M (64.79% of installed RAM)
[OK] Maximum possible memory usage: 804.0M (80.99% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory

Settings in my.cnf:

innodb_buffer_pool_size = 128M
innodb_log_file_size = 128M
key_buffer_size = 64M
long_query_time = 3

Would really appreciate some suggestions as how to proceed from here to figure out what is consuming my memory and causing the issues.

  • 1
    Kinda off-topic, as it's more a sysadmin question. Your PHP/Apache/nginx/whatever processes aren't going to be left with much to play with. 1Gb of RAM doesn't go far these days. – Philᵀᴹ Apr 21 '17 at 7:58

1GB is "tiny" today.

Swapping is terrible for MySQL performance, so it is important not to tune things too big.

max_allowed_packet -- dangerously high, change to 30M; if you really need more than that, then either get more RAM, or we can dig deeper to find some other solution.

Change max_connections to, say, 40.

Change open_files_limit to, say, 1000.

Can you ferret out the specific error when "establishing a database connection"? That might help, too.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.