MySQL crash randomly every few days.

  • Posted November 2, 2013

Previously it has similar problem, but after I enabled the SWAP file, it actually solve the problem. But recently the similar error came out again and the Mysql crash randomly every few days. Error message as below:

131102 5:59:34 [Note] Plugin ‘FEDERATED’ is disabled. 131102 5:59:34 InnoDB: The InnoDB memory heap is disabled 131102 5:59:34 InnoDB: Mutexes and rw_locks use GCC atomic builtins 131102 5:59:34 InnoDB: Compressed tables use zlib 1.2.7 131102 5:59:34 InnoDB: Using Linux native AIO 131102 5:59:34 InnoDB: Initializing buffer pool, size = 1.0G InnoDB: mmap(1098907648 bytes) failed; errno 12 131102 5:59:34 InnoDB: Completed initialization of buffer pool 131102 5:59:34 InnoDB: Fatal error: cannot allocate memory for the buffer pool 131102 5:59:34 [ERROR] Plugin ‘InnoDB’ init function returned error. 131102 5:59:34 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 131102 5:59:34 [ERROR] Unknown/unsupported storage engine: InnoDB 131102 5:59:34 [ERROR] Aborting

131102 5:59:34 [Note] /usr/sbin/mysqld: Shutdown complete

My Droplet is 1GB ram with 2GB swap on.

Should I enlarge the swap file? Any help will be greatly appreciate.



Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.


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


You can check if the MySQL innodb_buffer_pool_size is not set to a value that exceeds the available RAM on your droplet.

You can also create a simple bash script to check if MySQL is running and if not to restart it.


# Check if MySQL is running
sudo service mysql status > /dev/null 2>&1

# Restart the MySQL service if it's not running.
if [ $? != 0 ]; then
    sudo service mysql restart

Run this script every 5 minutes using a cron job like this one:

 */5 * * * * /home/user/scripts/ > /dev/null 2>&1

Hope that this helps! Regards, Alex

I don’t recommend creating a large swap file – 512MB should suffice. <br> <br>In this case I recommend upgrading your droplet as it simply doesn’t have enough RAM to host all of the programs running on it.

I would be careful with swap. it can slow things down sometimes

yes you should increase it to 4GB and I would not expect you to have any other issues. The only other time I used to get that error is if I ran out of disk space from log files.