MySQLD Dead But Subsys Locked - Troubleshooting MySQL Recurring Issue

Overview

On Amazon EC2 micro instances, it seems fairly common for MySQL to become unavailable on a recurring basis, with the following message returned by the service mysqld status command: mysql dead but subsys locked. This article explains how to address this issue.

Credits

The following article was adapted from the following pages.


Short Term Solution

Simply restarting the MySQL service via the following command seems to fix the issue, at least temporarily.

service mysqld restart

Long Term Solution

The first article in the Credits section above suggests that this may be a memory issue, which can be solved by creating a swap file for MySQL, as follows.

1. Shut down MySQL service

service mysqld stop

2. Create a swap file. (This will take a few moments)

dd if=/dev/zero of=/swapfile bs=1M count=1024

3. Implement the swap file

mkswap /swapfile
swapon /swapfile
chmod 0600 /swapfile

4. Configure MySQL to use the swap file by adding the following line to /etc/fstab

/swapfile swap swap defaults 0 0

5. Start MySQL service

service mysqld start