今天MySQL,出了點小問題。遂記之。現描述如下:
啟動MySQL
./bin/mysqld_safe --user=mysql &
莫名其妙的出現這一行:
mysqld_safe mysqld from pid file /usr/local/mysql/data/mark.pid ended
根據經驗,一定是沒有啟動MySQL,果然netstat -na | more沒有看到3306
查看錯誤記錄檔:
cd /usr/local/mysql/data<br />cat mark.err
//////////////////////////////////////////////////////////////////////////////////////////////////<br />110510 09:59:40 mysqld_safe mysqld from pid file /usr/local/mysql/data/mark.pid ended<br />110510 10:01:16 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data<br />110510 10:01:16 [Note] Plugin 'FEDERATED' is disabled.<br />110510 10:01:16 InnoDB: The InnoDB memory heap is disabled<br />110510 10:01:16 InnoDB: Mutexes and rw_locks use InnoDB's own implementation<br />110510 10:01:16 InnoDB: Compressed tables use zlib 1.2.3<br />110510 10:01:16 InnoDB: Using Linux native AIO<br />110510 10:01:16 InnoDB: Initializing buffer pool, size = 128.0M<br />110510 10:01:16 InnoDB: Completed initialization of buffer pool<br />110510 10:01:16 InnoDB: highest supported file format is Barracuda.<br />110510 10:01:16 InnoDB: Waiting for the background threads to start<br />110510 10:01:17 InnoDB: 1.1.6 started; log sequence number 1610190<br />/usr/local/mysql/bin/mysqld: File './mysql-bin.000006' not found (Errcode: 13)<br />110510 10:01:17 [ERROR] Failed to open log (file './mysql-bin.000006', errno 13)<br />110510 10:01:17 [ERROR] Could not open log file<br />110510 10:01:17 [ERROR] Can't init tc log<br />110510 10:01:17 [ERROR] Aborting<br />110510 10:01:17 InnoDB: Starting shutdown...<br />110510 10:01:18 InnoDB: Shutdown completed; log sequence number 1610190<br />110510 10:01:18 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete<br />/////////////////////////////////////////////////////////////////////////////////////////////////
解決辦法:
看到Failed to open log (file './mysql-bin.000006', errno 13) 然後,
cd /usr/local/mysql/data<br />rm -f mysql-bin.*
ok,搞定!
再次啟動,成功。
嘿嘿,/usr/local/mysql/data下面終於出現 mark.pid.
造成這種原因是因為突然斷電或者強制關機,沒有正常退出MySQL。只是估計。
還有一種情況導致這個錯誤的發生:
修改了 /etc/my.cnf 檔案(這個檔案是從 mysql 安裝目錄ln -s 過來的,具體可以看http://blog.csdn.net/androidbluetooth/article/details/6394301),比如說修改 mysql 預設字元集編碼等。
如果出現類似上述現象,請將該檔案恢複到原來的內容,按照前面所說的刪除 mysql-bin.*檔案,再次啟動 mysql 即可!