New $5 MySQL/Wordpress Crashing — InnoDB memory issue

We’ve set up a few independent websites using a minimum $5 droplet, using WordPress and MySQL.

In the minimum config, doing stuff in the admin panel, MySQL crashes regularly. This means we get an “Error — Failed to create a database connection”. When I go into the droplet via ssh I have to restart the service, using

It’s the latest version of the droplet (set up in mid and late 2019), using Ubuntu 18.04, and WordPress 5.0+.

service mysql start

The mysql error log shows

2020-01-14T20:00:24.293860Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2020-01-14T20:00:24.293878Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2020-01-14T20:00:24.293885Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-01-14T20:00:24.293895Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-01-14T20:00:24.307238Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-01-14T20:00:24.307284Z 0 [ERROR] Failed to initialize builtin plugins.
2020-01-14T20:00:24.307291Z 0 [ERROR] Aborting

2020-01-14T20:00:24.308788Z 0 [Note] Binlog end
2020-01-14T20:00:24.315381Z 0 [Note] Shutting down plugin 'CSV'
2020-01-14T20:00:24.319326Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

Based on this, it seems some problem with InnoDB and memory.

This is a blog with almost zero traffic, and only two logged-in users, doing very basic things like uploading images. It seems to happen because we’re trying to do something, but sometimes the server fails on its own.

The InnoDB buffer size is set at default currently - 128MB.

In the past, I’ve only been able to fix this by upgrading to a $10 droplet, but is that necessary? I think there may be a configuration issue.

Thanks in advance.

Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, all

The key error here is:

140707 23:37:13 InnoDB: Fatal error: cannot allocate memory for the buffer pool

This crash is due to your system running out of memory. I’d suggest that you add a swap file to give yourself a bit more of a buffer. Check out this tutorial:

How To Add Swap on Ubuntu 14.04

What you can also do is to use the MySQLTuner script.

The MySQLTuner is a script written in Perl and allows you to quickly test your MySQL configuration and it gives you suggestions for adjustments to increase performance and stability.

According to the official GitHub page, it supports 300 indicators for MySQL/MariaDB/Percona Server in this last version.

To run the script you could do the following:

  • SSH to your Droplet
  • Download the script:
wget -O
  • Then execute it:

The script would run multiple checks against your MySQL instance, all checks done by MySQLTuner are documented here.

Also as stated in the official documentation, it is still extremely important for you to fully understand each change you make to a MySQL database server. If you don’t understand portions of the script’s output, or if you don’t understand the recommendations, you should consult a knowledgeable DBA or system administrator that you trust.

As a good practice make sure to always test your changes on staging environments before implementing them on your production database.

On the same note, if you want to have a worry-free MySQL hosting and focus on your application, I would recommend trying out the DigitalOcean Managed Databases:

This was mini tutorial was posted from @bobbyiliev in this question in our community:

Hope that this helps! Regards, Alex

Hi @danaab272c4056f8633ea36d3a,

Here are the basic requirements for a WordPress website without doing anything on it :

Disk Space: 1GB+
Web Server: Apache or Nginx.
Database: MySQL version 5.6. 15 or greater or any version of MariaDB.
RAM: 512MB+
PHP: Version 7.3 or greater.
Processor: vCPU 2

This is just for the installation without anyone working on the website. Now, this doesn’t mean you can’t optimize your droplet so that it performs better under the website.

I’ll recommend installing Opcache as well as PHP-FPM, it really does wonders to your setup.

Additionally, if your Database is being killed so often, it would mean as you most probably know it’s being killed by your server as there is RAM shortage, this is indeed not how it’s suppose to react. I’ll assume you don’t have any SWAP enabled which is again part of the issue.

I’ll recommend enabling 1 or 2 GB of SWAP on your droplet and this will actually help with the errors you are experiencing.

Regards, KDSys