No, you do not want to go there. Why ?
The mysqld_safe script is responsible for creating and destroying the PID file
You can see it when you grep for it
$ MYSQLD_SAFE_SCRIPT=`which mysqld_safe`
$ grep -n pid_file < ${MYSQLD_SAFE_SCRIPT}
26:pid_file=
198: --pid-file=*) pid_file="$val" ;;
638:if test -z "$pid_file"
640: pid_file="$DATADIR/`hostname`.pid"
642: case "$pid_file" in
644: * ) pid_file="$DATADIR/$pid_file" ;;
647:append_arg_to_args "--pid-file=$pid_file"
720:if test -f "$pid_file"
722: PID=`cat "$pid_file"`
731: rm -f "$pid_file"
732: if test -f "$pid_file"
735:$pid_file
782: rm -f $safe_mysql_unix_port "$pid_file" # Some extra safety
796: if test ! -f "$pid_file" # This is removed if normal shutdown
834: numofproces=`ps xaww | grep -v "grep" | grep "$ledir/$MYSQLD\>" | grep -c "pid-file=$pid_file"`
840: PROC=`ps xaww | grep "$ledir/$MYSQLD\>" | grep -v "grep" | grep "pid-file=$pid_file" | sed -n '$p'`
859:log_notice "mysqld from pid file $pid_file ended"
$
What you should do is
service mysql stop
... delete the pid file if it is still exists after shutdown
service mysql start
If you have to restore backups from MySQL Enterprise, make sure there is no PID file.
Preferably, you could setup MySQL Replication and do the backups on the Slave. Then, when it is time for backup, run
STOP SLAVE;
SET GLOBAL innodb_fast_shutdown=0;
service mysql stop (The pid file should get deleted by mysqld_safe)
- Make your backup
service mysql start (The pid file should get created by mysqld_safe)
CAVEAT
If you ever have a problem with service mysql stop taking forever and still not shutting down mysqld, this quickly indicates that the socket file is missing. PID file will be out of whack as well.
In that happens, do a TCP/IP shutdown of MySQL
First do this
mysqladmin -uroot -p -h127.0.0.1 --protocol=tcp ping
If this echoes
mysqld is alive
then you can run
mysqladmin -uroot -p -h127.0.0.1 --protocol=tcp shutdown
GIVE IT A TRY !!!