Forum Diskusi dan Komunitas Online

Full Version: MySQL table "marked as crashed" or InnoDB won't start ? A free checklist before panic
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
There are few things that can hurt a Database Administrator more deeply than a MySQL server that won't start, or a table suddenly claiming "Table is marked as crashed and last repair failed." This usually happens after a power outage, a kill signal for the mysqld process, the disk getting filled, or copying the data folder while the database was running. Some issues are easily fixed with free tools, as long as you follow a careful procedure.
The most important step is to make sure that no writes happen to the current DB. If possible, shut it down cleanly, and copy the entire data directory to another location (make sure to copy the ibdata1, the ib_logfile files, and all .frm, .ibd, .MYD, and .MYI files). All steps below should be carried out on the copy and only after the previous ones have been performed.

MySQL MyISAM tables: Free Options
  1. Use CHECK TABLE (or mysqlcheck) to evaluate what's really wrong.
  2. Repair the table (REPAIR TABLE) or myisamchk while the database is stopped, using the recover option. If this fails, try using the safer mode if available.
  3. If the index file is missing or the header is corrupt, REPAIR TABLE ... USE_FRM will recover the index based on the table definition.

MySQL InnoDB tables: Free Options
  1. Look at the MySQL error log first. It should identify the issue.
  2. If the database doesn't start, use the innodb_force_recovery option in the config, with increasing values as needed.
  3. Once the server starts, extract the data with mysqldump and import it on a new instance.
  4. If you have binary logs and a recent backup, try restoring the backup and replaying the logs up to the point of failure.

Common Mistakes That Lead to Data Loss:
  • Trying to recover the data on the same data directory that the database is running on.
  • Using too high of a value for innodb_force_recovery. Values 4 and higher are very dangerous and should only be used as a last resort.
  • Deleting the ibdata1 or the ib_logfile files in an attempt to recover the database.
  • Using REPAIR TABLE on a MyISAM table without a proper backup, since it may delete the rows it can't recover.
  • Copying the data directory while the server was running.
  • Moving files between dissimilar versions of MySQL.
  • Continuing to attempt a recovery on a failing disk, which will cause new corruption.
  • Not having backups or binary logs enabled.

Best Way to Recover with Professional Tool
If the built-in tools don't work, or the tables are too damaged to be dumped, the Kernel for MySQL Database Recovery tool can recover corrupt InnoDB and MyISAM tables, and recover tables, indexes, keys, triggers, and views, with a free trial that lets you preview the recovered data before saving.
What error message did you get and did myisamchk or innodb_force_recovery help in any way?