I never had any issues with MySQL on an amazon ec2 instance until one client of mine had a website that kept crashing. I located the MySQL log file and kept seeing the following fatal error:
Fatal error: cannot allocate memory for the buffer pool…
There were other errors, but a fatal error is the one I wanted to look into first as it is the one stopping the server.
Here is how I solved this issue. I hope it helps someone with a similar problem:
First, it is always a good idea to back up your MySQL databases on the server in case something goes wrong.
Then I tried deleting any unused databases, tables and data to allow for more disk space as that seemed to be an issue. However, after doing so, I checked the memory available on the webserver by issuing a df command from the command line and found that there was clearly plenty of space available before and after deleting the data from the databases. Therefore this was not apparently my issue. Logic brought me to thinking that if there was plenty of disk space and there was still an error related to memory, there may be something wrong with the swap. I came to discover that the micro instance I was using didn’t have a swap space and that was cause for alarm because as far as I know, swap is needed to initialize the database engines.
Therefore, please follow the following link to my tutorial on how to add swap space to a Linux amazon ec2 instance if you are having similar issues. This should work on any Linux web server by the way: