2

I am running MySQL on a linux server. I have taken a copy-back mysql enterprise backup from another linux full backup. Ever sense then I have had problems getting MySQL to start. The problem is that MySQL is not updating the PID file, it's not even create a PID file. Is there anyway that I can manually create a PID for the MySQL instance?

One work around that I have been able to implement is the using the mysql-debugger which creates its own pid, but when I stop the debugger it still won't create/update the PID file.

1 Answer 1

1

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 !!!

2
  • So when I run "./usr/bin/mysqld_safe" the server starts up fine but when I run "service mysql start" it shoots an error: Starting MySQL.The server quit without updating PID file
    – asdf
    Apr 20, 2016 at 16:49
  • If you ran mysqld_safe, it already created a PID. If you run service mysql start, that runs mysqld_safe again. That will whack the socket file and the PID will be different. I wrote about why you should not do that : dba.stackexchange.com/questions/132697/my-mysql-server-died/… Apr 20, 2016 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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