Thursday, December 30, 2010

How to repair MySQL database when the Error 145 occurs

In MySQL databases, the MyISAM table is the default database engine, which provides a variety of functions to manage fields and indexes. These tables are best used for table locking, which makes it very useful while performing real-time transactions on the websites. However, when these tables get corrupt due to any random reason it makes the trading done on the web very insecure. In such cases, you should try to repair MySQL table using some appropriate methods. If none of the methods succeed, then I would recommend you to use a third-party MySQL Repair software to repair MySQL database.

Taking a practical case into consideration in which the following error message is displayed while you are working on a MyISAM table in the MySQL database:

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

The root cause of this problem is that the MyISAM table has corrupted as there is no more space in it to hold more data.


To overcome this MyISAM table corruption, you need to perform MySQL repair. For this, you should perform the following steps:

Create a backup copy of the database in case something goes wrong during the MySQL recovery.
Stop the mysqld server by killing the process in the Task Manager.
Run the following command to repair the index file to perform quick MySQL recovery:
myisamchk -r -q
If that does not work, then try the following command to perform a detailed scan and repair, if any, of the MyISAM table.
myisamchk --safe-recover
if the previous method also fails, then create a new blank database using the following commands:
shell> mysql db_name
mysql> SET autocommit=1;
mysql> TRUNCATE TABLE tbl_name;
mysql> quit
copy the contents of problem database in the new one.
Restart the mysqld server to check if the problem has been resolved or not.

If the problem is still not resolved, then you must use a third-party MySQL repair software to repair MySQL database. The key features of these MySQL recovery tools are the use of powerful but safe scanning algorithms in a user friendly interface thereby ensuring safe and easy recovery of MySQL database.

The best MySQL repair software that I would suggest you in this case is Stellar Phoenix Database Recovery for MySQL, which repairs MySQL files created in MySQL 3.x, 4.x, 5.x, and 6.x versions. With the ability to recover MySQL components such as tables, views, primary keys, etc, this MySQL recovery tool supports both InnoDB and MyISAM database engines. It is compatible with Windows 7, Vista, Server 2003, XP, and 2000.
Article Source:

About the Author

My name is Mark Willium, I have done Ph.D in computer science and currently doing research on how to repair mysql database.

1 comment:

  1. This comment has been removed by a blog administrator.