Tuesday, April 3, 2012

How to rectify MySQL error code 145

MySQL logo
MySQL logo (Photo credit: tmolini)
If MySQL Server is unable to open MyISAM tables and reporting an error message i.e. “MySQL error code 145”. It reflects that MyISAM tables got damaged. 

Full description of the error:

“MySQL error code 145 = Table was marked as crashed and should be repaired”

What is MyISAM database engine: 

It is a default storage engine for MySQL database. MyISAM supports three types of file .frm, .myd & .myi and these files stores in tables. These file types such as:
The .MYD: called data file  [USE images]
The MYI: called index file.
The .FRM: used to store the definition of the table. 

How should I know if MyISAM files get corrupted or not?

You can identify corruption by considering following points:
  • Once you get an error message during selecting data from the table. For example: “MySQL error code 145”
  • If Queries don't find rows in the table.
  • If Queries returns incomplete results.
You can check MyISAM table corruption by using the CHECK TABLE statement.

How to repair corrupted MyISAM files:
 
You can easily repair corrupted MyISAM files either by using REPAIR TABLE command or by using myisamchk command. But first you should read the following points before using these commands:

  • First make sure you have created the backup before using any repair command.
  • myisamchk does not support partitioned tables but REPAIR TABLE command supports partitioned tables.
  • Befor using myisamchk, first stop MySQL Server.
  • Also ensure that no other application is using tables while you are running myisamchk command.

What if MySQL Inbuilt utilities doesn't repair corrupt MyISAM files:
 
If above Inbuilt utilities are giving you an error message while you are trying to recover your corrupt MyISAM tables or if you are still unable to open MyISAM tables then you need to try an appropriate third party MySQL Recovery tool to fixed table corruption. These software repairs corrupted tables as well as other corrupted MySQL database objects. It also repair corrupt MySQL database when MySQL inbuilt utilities are unable to do that.
Enhanced by Zemanta

No comments:

Post a Comment