To prevent the problem from occurring, you must perform a graceful shutdown of the server from the command line rather than powering off the server.
This will stop the running services before powering down the machine.
Based on Centos, an additional method for getting it back up again when you run into this problem is to move mysql.sock:
Restarting the service creates a new entry called mqsql.sock
Create a service in “automator” that passes two files/folder arguments to a bash script that calls your diff utility.
Note: For those using Apple’s FileMerge, the command-line tool is called “opendiff”.
Find more details on Apple Site : Mac Basics: Automator