1. 程式人生 > >MySQL錯誤修復:Table xx is marked as crashed and last (automatic?) repair failed

MySQL錯誤修復:Table xx is marked as crashed and last (automatic?) repair failed

有站長找到我,說資料庫壞了,訪問網站報錯如下:

Error establishing a database connection

看了下 MySQL 的錯誤日誌,報錯如下:

Error: Table './db_name/table_name' is marked as crashed and last (automatic?) repair failed

修復很簡單,先停止 MySQL:service mysqld stop

進入到 MySQL 資料庫的檔案存放目錄,比如 cd /data/mysql/zhangge_db

然後執行如下命令:

1 myisamchk--safe-recover-f-r *.MYI

執行完成後,為了保險起見,我們要將檔案的許可權改回 MySQL 的執行賬號(自行檢視),比如 mysql:

1 chown-Rmysql:mysql.

啟動 MySQL:service mysqld start

最後,執行再次自動修復優化命令即可解決:

1 mysqlcheck--auto-repair--optimize--all-databases-p密碼