mysqld dead but subsys locked I'm executing the following command in a shell script and I'm executing this on an RHEL-6 server and MySQL version 5.1.47-

mysqld_safe --defaults-extra-file=/custom/path/of/my.cnf


The path of my.cnf can be anything. (If I am not wrong, as a developer we cannot determine where mysql could be installed.) After the above command in the script, there are a few mysql commands to be executed. When the script executes the above command, the output console displays that the mysql service has successfully started. But when the control comes to the part where the mysql commands are to be executed, the following error message comes up-

mysqld dead but subsys locked


Any idea where I am going wrong?

This is what my my.cnf contains-

[mysqld]
innodb_log_buffer_size=8M
innodb_flush_log_at_trx_commit=1
innodb_file_io_threads=4
max_binlog_size=20M
max_allowed_packet=16M
max_connections=500
log_bin=logFile.log
binlog-do-db=test
server-id=1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
binlog-format=ROW
log_warnings=1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
For me, this means that the daemon has crashed and was restarted, but the lockfile that mysqld uses to prevent multiple daemons from accessing the same database is still there...

I fix it with

service mysqld stop
service mysqld start


Not sure if you can just to a restart instead of a stop then start, and I haven't figured out the cause yet for the crash either.