MySQL table is marked as crashed

后端 未结 1 1017
遥遥无期
遥遥无期 2021-01-12 17:36

I fairly new to MySQL database. I am repeatedly seeing an error from MySQL saying the table is marked as crashed and should be repaired. However I am able to repair the cras

相关标签:
1条回答
  • 2021-01-12 18:04

    MyISAM tables are very easy to crash. There is header info in each table that keeps track of how many open file handles a MyISAM table has.

    If mysqld crashes, any MyISAM table that had open file handles to it never had the opportunity to decrement the file handle count upon each file handle closing. Thus, if a new file handle opens a MyISAM table (.MYD file) and mysqld discovers a mismatch between the number of file handles a MyISAM table believes is open and the the number of file handles the MyISAM table actually has open, the table is declared crashed.

    There are four(4) methods for handling this:

    METHOD #1 : Setup automatic MyISAM repair

    See my post https://dba.stackexchange.com/a/15079/877 on how to set this up upon a MySQL restart (Mar 15, 2012)

    METHOD #2 : Use InnoDB instead of MyISAM

    InnoDB has crash recovery built into the Storage Engine's initialization. MyISAM does not

    METHOD #3 : Use Aria instead of MyISAM

    Aria is MariaDB's drop-in replacement for MyISAM. It features crash recovery mechanisms for individual tables.

    METHOD #4 : Don't kill -9 on mysqld

    If mysqld crashes, deliberately or involuntarily, header info for all open MyISAM tables will get them into a crashed state. Avoid having to manually kill mysqld.

    0 讨论(0)
提交回复
热议问题