Mysql shut down problem In Ubuntu


While my external app is working on server. It always shut down and failed to connect again.

What is the problem. thanks

Error log

2020-03-11T15:35:38.507160Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2020-03-11T15:35:38.511341Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000) 2020-03-11T15:35:39.657307Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2020-03-11T15:35:39.683864Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.29-0ubuntu0.16.04.1) starting as process 3244 … 2020-03-11T15:35:39.776947Z 0 [Note] InnoDB: PUNCH HOLE support available 2020-03-11T15:35:39.779305Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2020-03-11T15:35:39.779410Z 0 [Note] InnoDB: Uses event mutexes 2020-03-11T15:35:39.779497Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2020-03-11T15:35:39.779580Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8 2020-03-11T15:35:39.779662Z 0 [Note] InnoDB: Using Linux native AIO 2020-03-11T15:35:39.780503Z 0 [Note] InnoDB: Number of pools: 1 2020-03-11T15:35:39.781534Z 0 [Note] InnoDB: Using CPU crc32 instructions 2020-03-11T15:35:39.805432Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2020-03-11T15:35:39.811489Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12 2020-03-11T15:35:39.811599Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 2020-03-11T15:35:39.811690Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2020-03-11T15:35:39.811895Z 0 [ERROR] Plugin ‘InnoDB’ init function returned error. 2020-03-11T15:35:39.812001Z 0 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed. 2020-03-11T15:35:39.812066Z 0 [ERROR] Failed to initialize builtin plugins. 2020-03-11T15:35:39.812127Z 0 [ERROR] Aborting

2020-03-11T15:35:39.812199Z 0 [Note] Binlog end 2020-03-11T15:35:39.812673Z 0 [Note] Shutting down plugin ‘MyISAM’ 2020-03-11T15:35:39.819977Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

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, @csselo

Looking at the provided output from the error_log it seems like the droplet/server is running out of memory:

2020-03-11T15:35:39.811599Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool

You can check if you’ve assigned a value that is too high (compared to the droplet’s total RAM/memory). You can check the available free memory with this command:

free -m

You can check the value of buffer pool size in /etc/my.cnf less than amount of free RAM:

cat /etc/my.cnf

Once you’ve set the value of the innodb_buffer_pool_size to be less than the available RAM on the droplet you can restart the mysql service:

systemctl restart mysql

Hope this helps!

Regards, Alex

Hello, @csselo

I’d suggest that you add a swap file to give yourself a bit more of a buffer. Check out this tutorial:

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:

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

Hello, @csselo

You will need to sort out the memory usage in order to resolve the problem with the MySQL service. As already mentioned you can monitor the server/droplet’s performance using top / htop and see the available free memory with free -m

You can check if the web server is busy handling requests and thus causing the memory exhaustion or if any other process is consuming the memory.

You can consider a memory upgrade as well, but I’ll suggest that you should check everything else before going for a memory upgrade.

Let me know how it goes.

Regards, Alex