Symptoms
-
MySQL/MariaDB service cannot start.
-
The errors like the following are shown when querying the status of the service:
Debian/Ubuntu:
# service mysqld status
mysqld dead but subsys lockedCentOS/RHEL:
# service mariadb status
ERROR! MariaDB is not running, but lock file (/var/lock/subsys/mysql) exists -
Amount of free memory on the server is low.
Cause
MySQL/MariaDB service failed because of lack of free memory and left the /var/lock/subsys/mysqld
file behind.
Resolution
It is required to remove /var/lock/subsys/mysqld
file, free up some memory, and start MySQL/MariaDB.
Note: Actions described below require administrative skills, in case you have any difficulties with it, reboot the server to fix the issue. Consider increasing the amount of RAM on the server in order to prevent such issues from happening in the future.
-
Log in to the server via SSH.
-
Remove
/var/lock/subsys/mysqld
file:# rm -f /var/lock/subsys/mysqld
-
Check the amount of free memory with "
free -m
" command. In case there is more then 200M free, skip this step. In case the amount of free memory is low, kill processes that consume most of the memory. For example, stop the Apache temporarily:Debian/Ubuntu:
# service apache2 stop
CentOS/RHEL:
# service httpd stop
-
Start MySQL/MariaDB:
Debian/Ubuntu:
# service mysqld start
CentOS/RHEL:
# service mariadb start
-
In case Apache is stopped on step 3, start it back:
Debian/Ubuntu:
# service apache2 start
CentOS/RHEL:
# service httpd start