I have an issue right now with my Server Ubuntu 16.04 and I was hoping someone could help or guide me to the solution.
I recently installed Wordpress and it worked fine for 3 days but now it is displaying the following error: “Error establishing a database connection”. It always crashes for a couple of seconds and then it works again, but this keeps happening all the time.
So I collected the logs for Mysql and I found this:

<^>2018-01-26T04:01:17.405635Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2018-01-26T04:01:17.405656Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2018-01-26T04:01:17.405666Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2018-01-26T04:01:17.405676Z 0 [ERROR] Plugin ‘InnoDB’ init function returned error.
2018-01-26T04:01:17.405683Z 0 [ERROR] Plugin 'InnoDB’ registration as a STORAGE ENGINE failed.
2018-01-26T04:01:17.405691Z 0 [ERROR] Failed to initialize builtin plugins.
2018-01-26T04:01:17.405697Z 0 [ERROR] Aborting

2018-01-26T04:01:17.405712Z 0 [Note] Binlog end
2018-01-26T04:01:17.408006Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2018-01-26T04:01:47.308940Z 0 [Warning] Changed limits: maxopenfiles: 1024 (requested 5000)
2018-01-26T04:01:47.308976Z 0 [Warning] Changed limits: tableopencache: 431 (requested 2000)
2018-01-26T04:01:47.467060Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicitdef aultsfortimestamp server option (see documentation for more details).
2018-01-26T04:01:47.468608Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-0ubuntu0.16.04.1) starting as process 5600 …
2018-01-26T04:01:47.472435Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-01-26T04:01:47.472454Z 0 [Note] InnoDB: Mutexes and rw
locks use GCC atomic builtins
2018-01-26T04:01:47.472458Z 0 [Note] InnoDB: Uses event mutexes
2018-01-26T04:01:47.472462Z 0 [Note] InnoDB: GCC builtin _atomicthreadfence() is used for memory barrier
2018-01-26T04:01:47.472478Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-01-26T04:01:47.472481Z 0 [Note] InnoDB: Using Linux native AIO
2018-01-26T04:01:47.472701Z 0 [Note] InnoDB: Number of pools: 1
2018-01-26T04:01:47.472810Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-01-26T04:01:47.474205Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-01-26T04:01:47.482501Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-01-26T04:01:47.484835Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-01-26T04:01:47.504123Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-01-26T04:01:47.506227Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 28060943
2018-01-26T04:01:47.506240Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 28060952
2018-01-26T04:01:47.506244Z 0 [Note] InnoDB: Database was not shutdown normally!
2018-01-26T04:01:47.506248Z 0 [Note] InnoDB: Starting crash recovery.
2018-01-26T04:01:47.689508Z 0 [Note] InnoDB: Removed temporary tablespace data file: “ibtmp1”
2018-01-26T04:01:47.689526Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-01-26T04:01:47.689556Z 0 [Note] InnoDB: Setting file ’./ibtmp1’ size to 12 MB. Physically writing the file full; Please wait …
2018-01-26T04:01:47.725880Z 0 [Note] InnoDB: File ’./ibtmp1’ size is now 12 MB.
2018-01-26T04:01:47.726525Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active .
2018-01-26T04:01:47.726535Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-01-26T04:01:47.726671Z 0 [Note] InnoDB: Waiting for purge to start
2018-01-26T04:01:47.776850Z 0 [Note] InnoDB: 5.7.21 started; log sequence number 28060952
2018-01-26T04:01:47.777089Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib
2018-01-26T04:01:47.778297Z 0 [Note] Plugin 'FEDERATED’ is disabled.
2018-01-26T04:01:47.787146Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180126 4:01:47
2018-01-26T04:01:47.787636Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context i s not usable without certificate and private key
2018-01-26T04:01:47.825642Z 0 [Note] Event Scheduler: Loaded 0 events
2018-01-26T04:01:47.825743Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.21-0ubuntu0.16.04.1’ socket: ’/var/run/mysqld/mysqld.sock’ port: 3306 (Ubuntu)
2018-01-26T04:01:48.311112Z 2 [Note] Access denied for user 'root’@'localhost’ (using password: NO)<^>

I’m definitely not a server expert, but I will appreciate if someone could tell what this means, and what solutions should I try

Thank you!

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.

2 answers

As it says: “Cannot allocate memory for the buffer pool”. You ran out of memory.

  • Thank you for your answer
    Is this something I can change in the server? To allow more memory?

    Or this? Do I need to change the limits? (don’t know how)
    Changed limits: maxopenfiles: 1024 (requested 5000)
    Changed limits: tableopencache: 431 (requested 2000)



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 http://mysqltuner.pl/ -O mysqltuner.pl
  • Then execute it:
perl mysqltuner.pl

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: https://www.digitalocean.com/community/questions/how-to-tweak-mysql-mariadb-configuration-for-increased-performance-and-stability

Hope that this helps!

Submit an Answer