14
Nov 09

Starting MySQL. ERROR! Manager of pid-file quit without updating file.

I got that nasty error after moving around different directories in /var/lib/mysql:

root@server:/var/lib/mysql# /etc/init.d/mysql start

Starting MySQL. ERROR! Manager of pid-file quit without updating file.

There were all kind of suggestions about it on the net, most of which had something to do with incorrect shutdown or incorrect permissions for the pid file.

One of the suggestions reminded me to read the mysql error log :) Here is what the error log said:

root@server:/var/lib/mysql# /etc/init.d/mysql start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.
root@server:/var/lib/mysql# mysql
mysql                       mysql_config                mysqldumpslow               mysql_idle_processes.pm     mysqlshow                   mysql_tzinfo_to_sql
mysqlaccess                 mysql_convert_table_format  mysql_explain_log           mysqlimport                 mysql_sock.pm               mysql_upgrade
mysqladmin                  mysqld                      mysql_find_rows             mysql_install_db            mysql_tableinfo             mysql_upgrade_shell
mysqlbinlog                 mysqld-debug                mysql_fix_extensions        mysql_logs.sh               mysqltest                   mysql_waitpid
mysqlbug                    mysqld_multi                mysql_fix_privilege_tables  mysqlmanager                mysqltestmanager            mysql_zap
mysqlcheck                  mysqld_safe                 mysqlhotcopy                mysql_secure_installation   mysqltestmanagerc
mysql_client_test           mysqldump                   mysqlhotcopy.orig           mysql_setpermission         mysqltestmanager-pwgen
root@server:/var/lib/mysql# mysqld
mysqld         mysqld-debug   mysqld_multi   mysqld_safe    mysqldump      mysqldumpslow
root@server:/var/lib/mysql# mysqld
mysqld         mysqld-debug   mysqld_multi   mysqld_safe    mysqldump      mysqldumpslow
root@server:/var/lib/mysql# mysqld_safe start
Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/lib/mysql/host.server.bgsnow.com.pid
091114 13:14:56  mysqld ended
root@server:/var/lib/mysql# ll /var/lib/mysql/host.server.bgsnow.com.p
root@server:/var/lib/mysql# touch /var/lib/mysql/host.server.bgsnow.com.pid
root@server:/var/lib/mysql# chown mysql: /var/lib/mysql/host.server.bgsnow.com.pid
root@server:/var/lib/mysql# /etc/init.d/mysql start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.
root@server:/var/lib/mysql# tail -f /var/lib/mysql
mysql/    mysqlA/   mysqlOLD/
root@server:/var/lib/mysql# tail -f /var/lib/mysql/mysql-slow.log
host.server.bgsnow.com.err  ib_logfile0                mysql-slow.log             optistr2_optistreams/
ibdata1                    ib_logfile1                optistr2_opti/             optistr2_perldesk/
root@server:/var/lib/mysql# tail -f /var/lib/mysql/host.server.bgsnow.com.err
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 43655
091114 13:16:20  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
091114 13:16:21  InnoDB: Started; log sequence number 0 43655
091114 13:16:21 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
091114 13:16:21  mysqld ended
091114 13:16:52  mysqld started
InnoDB: Log scan progressed past the checkpoint lsn 0 36808
091114 13:16:52  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 43655
091114 13:16:52  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
091114 13:16:53  InnoDB: Started; log sequence number 0 43655
091114 13:16:53 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
091114 13:16:53  mysqld ended
root@server:/var/lib/mysql# ls
./  ../  host.server.bgsnow.com.err  ibdata1  ib_logfile0  ib_logfile1  mysql-slow.log  optistr2_opti/  optistr2_optistreams/  optistr2_perldesk/
root@server:/var/lib/mysql# ll ../
alternatives/     dhclient/         logrotate.status  mlocate/          mysqlA/           pgsql/            rkhunter/         sepolgen/         stateless/        yum/
dbus/             games/            misc/             mysql/            mysqlOLD/         random-seed       rpm/              spamassassin/     texmf/
root@server:/var/lib/mysql# ll ../
alternatives/     dhclient/         logrotate.status  mlocate/          mysqlA/           pgsql/            rkhunter/         sepolgen/         stateless/        yum/
dbus/             games/            misc/             mysql/            mysqlOLD/         random-seed       rpm/              spamassassin/     texmf/
root@server:/var/lib/mysql# ll ../mysqlOLD/
cphulkd/                   host.server.bgsnow.com.err  ib_logfile0                mysql/                     roundcube/                 sentry_stat/
eximstats/                 host.server.bgsnow.com.pid  ib_logfile1                mysql-slow.log             sentry/                    sentry_traf/
horde/                     ibdata1                    leechprotect/              mysql.sock                 sentry_mambo/              test/
root@server:/var/lib/mysql# ll ../mysqlOLD/*
root@server:/var/lib/mysql# ls
./  ../  host.server.bgsnow.com.err  ibdata1  ib_logfile0  ib_logfile1  mysql-slow.log  optistr2_opti/  optistr2_optistreams/  optistr2_perldesk/
root@server:/var/lib/mysql# mv ../mysqlOLD/
cphulkd/                   host.server.bgsnow.com.err  ib_logfile0                mysql/                     roundcube/                 sentry_stat/
eximstats/                 host.server.bgsnow.com.pid  ib_logfile1                mysql-slow.log             sentry/                    sentry_traf/
horde/                     ibdata1                    leechprotect/              mysql.sock                 sentry_mambo/              test/
root@server:/var/lib/mysql# mv ../mysqlOLD/* ./
mv: overwrite `./host.server.bgsnow.com.err'? y
mv: overwrite `./ibdata1'? n
mv: overwrite `./ib_logfile0'? n
mv: overwrite `./ib_logfile1'? n
mv: overwrite `./mysql-slow.log'? y
root@server:/var/lib/mysql# /etc/init.d/mysql restart
Shutting down MySQL. SUCCESS!
Starting MySQL. SUCCESS!

root@server:/var/lib/mysql# tail -f /var/lib/mysql/host.server.bgsnow.com.err

InnoDB: Restoring possible half-written data pages from the doublewrite

InnoDB: buffer...

InnoDB: Doing recovery: scanned up to log sequence number 0 43655

091114 13:16:20  InnoDB: Starting an apply batch of log records to the database...

InnoDB: Progress in percents: 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

InnoDB: Apply batch completed

091114 13:16:21  InnoDB: Started; log sequence number 0 43655

091114 13:16:21 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

091114 13:16:21  mysqld ended

Obviously I have forgotten to move back the mysql directory which is responsible for the database for all privileges, databases and so on :)  So moving it back along with the rest of the core files solved the problem:

root@server:/var/lib/mysql# mv ../mysqlOLD/* ./

mv: overwrite `./host.server.bgsnow.com.err'? y

mv: overwrite `./ibdata1'? n

mv: overwrite `./ib_logfile0'? n

mv: overwrite `./ib_logfile1'? n

mv: overwrite `./mysql-slow.log'? y

root@server:/var/lib/mysql# /etc/init.d/mysql restart

Shutting down MySQL. SUCCESS!

Starting MySQL. SUCCESS!

Thus if you have similar problems, the first thing is to check the MySQL error log and don't believe the misleading error about the PID :)