Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do freelance IT consulting for various clients, both in Toronto, Canada, and worldwide.

A client recently experienced a power failure. Now they've been having various problems with a Slackware 12.0.0 machine which also acts as a DNS server.

One problem is that they can't log into phpMyAdmin.

I tried stopping and restarting MySQL. But even when MySQL is stopped, the lock file stays around.

jasonspiro@cybertron:~$ sudo /etc/init.d/mysql stop 
Shutting down MySQL. SUCCESS! 
jasonspiro@cybertron:~$ sudo /etc/init.d/mysql stop
 ERROR! MySQL manager or server PID file could not be found!
jasonspiro@cybertron:~$ sudo /etc/init.d/mysql status
 ERROR! MySQL is not running, but lock exists
jasonspiro@cybertron:~$ ls -l /var/lock/subsys/mysql 
-rw-r--r-- 1 root root 0 2012-07-05 16:18 /var/lock/subsys/mysql

Why is MySQL's lock file hanging around despite the fact that MySQL isn't running?

Can I simply stop MySQL, delete the lock file, and start MySQL again?

Are there any other steps that I should take next, or nothing?

EDIT: A while after I asked this question, I noticed that the way MySQL is installed on this machine seems wonky. Also, I found out that the /etc/init.d/mysql script I found on this machine always creates a lock file when it starts MySQL and never deletes the file when it stops MySQL. So this question turns out to be irrelevant to me. Thank you, but I don't need more answers to this question.

share|improve this question
Lock files are only removed during a graceful shutdown. Power-failures do not qualify :-) – Mike Pennington Jul 5 '12 at 20:32
The lock is in /var/log/run – Andrew Smith Jul 5 '12 at 20:32
@AndrewSmith: Thanks for your reply. I don't have a /var/log/run directory. Am I supposed to? – jasonspiro Jul 5 '12 at 20:36
up vote 9 down vote accepted

Do: ls -al /var/lock/subsys

Look for Remove that. Also remove mysql.sock if it exists.

If all else fails, [as root] use updatedb ; locate <filename>. This is your friend in situations like this.

Try restarting MySQL using the init script. If that doesn't work, restore to a database checkpoint from an acceptable backup of the database.

If no database backups exist: Make a clone of this disk with dd ASAP. You may need to use some hard-core recovery procedures. Even if the MySQL service starts back up again, save the best known-good backup for a while, just in case.

share|improve this answer
MySQL starts up fine now. No data was lost. Thank you for the answer you posted above. – jasonspiro Jul 10 '12 at 22:18
You are most welcome, best of luck to you on your project. – Mike Pennington Jul 11 '12 at 1:30
what is the lock state for anyways? this just happened to me. – duckx Jul 10 '15 at 13:51
@duckx, please see this answer (on SF) and this answer (on SO) – Mike Pennington Jul 12 '15 at 18:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.