mysql is dead but subsys locked
Solution 1
I had this problem with my OTRS server after I tried to update a to large package.
The solution was:
copy for safty:
cp /var/lock/subsys/mysqld /root/mysqld
than delete it
rm /var/lock/subsys/mysqld
than close all services that depends on mysql:
service httpd stop
service otrs stop
after that:
service mysqld restart
service httpd restart
service otrs restart
System is CentOS 6.x
Solution 2
service mysqld restart
Simply restarting the mysqld worked fro me on Centos.
Solution 3
- tail /var/log/mysqld.log to check the error log
then do the following actions:
rm /var/lock/subsys/mysqld chown -R mysql.mysql /var/run/mysqld
Solution 4
first,make sure that /etc/init.d/mysqld is running from /usr/local/mysql/bin then,kill mysqld ,delete the lock file and restart it.
Solution 5
This (and all sorts of other weird errors) can also happen if you have a full disk. In my case, my /var partition had filled up. Freeing up space allowed mysqld to restart again.
Related videos on Youtube
Vedant Terkar
Unsung hero, they say... I'm from: India A Proud Indian in the USA Helping the world full of Programmers! Together We Grow :).
Updated on March 17, 2020Comments
-
Vedant Terkar about 4 years
I am using PHP-mysql on Linux (RHEL 5.0) For First Time
When I tried to connect to MySQL from my PHP Script using mysqli_connect.
It Displayed The Following Error:Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'(2)
After googling for hour I found solution to this as stated here.
When I followed that approach and issued command:
service mysqld status
as a root user I got :
mysql is dead but subsys locked
Any one know how to solve this and cause of this error ?Also
- Restarting
- Starting
- And Stopping of MySQL
But PHP is working fine. I've tested thephpinfo();
for Demo.
I've installed MySQL in/usr/local/mysql/bin
. Can Anyone Help me in this ? Any help is appreciated.
Thanks in advance.-
Hanky Panky over 10 yearsRestart the whole server
-
Vedant Terkar over 10 years@Hanky웃Panky Tried it before posting the question. But it is of No use.
-
Cwissy over 10 yearsHave you actually looked at the mysql log file to see what the error could possibly be rather than just wildly plucking stuff out of the air?
-
Gijo Varghese over 7 years@VedantTerkar is there any permanent solution for this? I'm getting this every few hours
-
Vedant Terkar over 10 yearsThanks For Your reply. Can you please elaborate how to do that? Specially The First part :
make sure that /etc/init.d/mysqld is running from /usr/local/mysql/bin
. because I'm very new to linux. I'm a Windows user. -
Vedant Terkar over 9 yearsYou know what, this question is now becoming a year old (Happy B'day to it :), in advance ), but I did the same at that time and that solved my problem. But I failed to post it as my answer here. So Thanks for posting. +1 and accepting this. Cheers :)!
-
Vedant Terkar over 9 yearsThanks for spending you time in solving this. +1.
-
Vedant Terkar over 9 yearsThanks for spending you time in solving this. +1.
-
Felipe almost 8 yearsThanks, mate. This did it. As mine's not CentOS I just didn't need to handle the "otrs". Cheers.
-
JonyD over 7 years+1. I just had this problem on a Amazon instance and this solved it. Two short notes: the /var/lock/subsys/mysqld file was empty (0 bytes); the service otrs was not installed on the machine.
-
Jovan Perovic over 7 yearsThanks a lot! However, I am looking for now for a root cause as it repeats itself every 24h :(
-
Gijo Varghese over 7 years@JovanPerovic is there any permanent solution for this? I getting this error every few hours. It's not easy to log in each time and fix this
-
Jovan Perovic over 7 years@GijoVarghese: I was able to confirm that OS OOM was triggered every single time prior to crash. I tried to pin point the root cause of OOM, but the crash would happen sometimes in the middle of the work hours and sometimes during the nightly backup (while doing nightly
mysql_dump
). Finally, I ran out of options and decided to contact the provider which said that my kernel was out of date and they have upgraded it to the latest. From that day on, I had not a single crash! Somehow, I find it hard to believe that it was kernel version and not something more serious, I have no proof. -
Gijo Varghese over 7 years@JovanPerovic I bought the basic plan from DigitalOcean (Centos 6.8 with 512MB ram). But if its a kernel issue, digitalocean would have already fixed it. I doubt its due to 512MB ram. Going to upgrade and try
-
Jovan Perovic over 7 yearsCool, try doing that. You might as well find something useful in my own question on SF: serverfault.com/questions/812629/…
-
Pankaj Kumar Katiyar over 7 yearsWell I did little research and followed these steps: first check what is the available swap memory and then check which process is consuming more memory using command top -H and kill that process and then restart the mysqld
-
sjas almost 6 yearsThis seems to happen on systems simply running out of memory where mysqld gets killed by the operation system OOM killer.