MySQL crash with Fatal error: cannot allocate memory for the buffer pool

It’s clearly a out of memory problem. But what to do other than adding physical memory?

  1. Add swap swap is your virtual memory on hard disk that can store memory content that can’t fit in your physical memory [bash] sudo fallocate -l 4G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile [/bash]

Also add to file /etc/fstab this line /swapfile none swap sw 0 0 So that it’s enabled after reboot. Source: How To Add Swap on Ubuntu 14.04

  1. Reduce MySQL bufffer size This might not be a good idea. Unless you understand clearly the load and requirement of your server, don’t reduce the default buffer size for MySQL. Create a MySQL conf file in /etc/mysql/conf.d and add the lines
      innodb_buffer_pool_size = xxxM
Written on March 24, 2016