I know that there are lots of questions about this out there but unfortunately none of the solution seems to fix my problem. I have been spending lot of time finding the solution and did not achieve much from my reading with my limited knowledge.
I am using Amazon free tier and hosting a WordPress site. I have installed LAMP and WordPress. The website is now in the development mode. Initially everything was good but after some time suddenly I started to receive problem of Error Establishing Database Connection very frequent.
Some findings when the problem appeared:
sudo service mysqld status
returnedmysqld dead but subsys locked
-
Deeper in the log:
InnoDB: Initializing buffer pool, size = 10.0M InnoDB: mmap(10731520 bytes) failed; errno 12 InnoDB: Completed initialization of buffer pool InnoDB: Fatal error: cannot allocate memory for the buffer pool Completed initialization of buffer pool InnoDB: Fatal error: cannot allocate memory for the buffer pool [ERROR] Plugin 'InnoDB' init function returned error. [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. [ERROR] Unknown/unsupported storage engine: InnoDB [ERROR] Aborting /usr/libexec/mysql55/mysqld: Shutdown complete
So what I have done are as below but none of them works for me yet:
- Restart
httpd
andmysqld
>>>>> OK for few minutes then got the problem again - Make swap file of 1GB >>>>> even 2GB did not work for me. OK for a while (few hours) but the problem come back
- Decreased
innodb_buffer_pool_size
down to 10MB but still not happy
I really have no idea on how to sort this issue. What I realized is whenever I start on the new server, it is good for a while then the problem comes. Any help and guidance are greatly appreciated.
Thanks.
All the above problems you have mentioned happens when you run MYSQL on a AWS free tier EC2 micro instance as it already has less memory. This problem will escalate more when you launch your site live. I will suggest you launch a separate AWS RDS MYSQL server in free tier and use that as the database for your WordPress website. Check this link AWS RDS Free Tier
You will have many advantages like there is no need to keep up with vendor security and performance patches when you use Amazon RDS, this is taken care of by the AWS. RDS also includes backup and recovery services, eliminating another common task on to-do lists.