I have Monit monitoring Mysql. When the machine shuts down abruptly eg a power failure, mysqld cannot be restarted unless /var/lib/mysql/mysql.sock is deleted, due to the error Another MySQL daemon already running with the same unix socket. What is the correct configuration to have Monit delete the file on bootup?
I joke that you should just buy a UPS... But protecting a server from sudden power loss is pretty easy. A basic UPS can provide that for you.
If those are not options (as I don't know the context of the environment and constraints), are you sure that you want the server and services coming up automatically following a hard crash with no manual intervention? If so...
Change the startup script in your Monit start command. For example:
check process mysqld with pidfile "/var/run/mysqld.pid" start program = "/sbin/service mysqld start" stop program = "/sbin/service mysqld stop"
Instead of using the mysqld start script, write a wrapper script that checks for the existence of the
Or maybe just have the start command be
/sbin/service mysqld restart, as that runs a
stop() followed by a
start(). In the init script, the stop command removes the sock file.