mysql error 145, 'Table is marked as crashed and

chris (2005-07-26 21:44:17)
29543 views
3 replies

This is just a quick note for those stuck with mysql error 145. Usually in these circumstances, MySQL will start just fine, the mysql> prompt will work, but attempts to read a particular table fail with error 145. This is usually a sign of a corrupted table. One common cause of this is the disk hitting 100%, so use df and du -sk / to try and figure out where your clogs are.

Once you're happy that the disk is okay, return to the mysql> prompt and run the following: check table table_name; where table_name is the name of your corrupted table. This may or may not fix the problem. This is basically the equivalent to running myisamchk, but without the range of options available with the full application.

Once again, you might find that you are still unable to access your table.MYI (that's the file which actually stores the information for the table). Your last resort is to exit mysql and run myisamchk from your shell prompt, passing in the 'recover' option. This can fix just about any MyISAM corruption and is done as follows:

/usr/bin/myisamchk -r /var/lib/mysql/database_name/table_name.MYI

Note that you may need to change those paths to point to your copy of myisamchk and your data directory. use 'find' and 'locate' to determin where they are on your system.

myisamchk -r is the most useful of all tools to the MySQL DBA in disaster recovery situations and has saved my skin on numerous occasions in the past..

christo
Digg it! Submit to Slashdot Add to Blinklist Del.icio.us Add to Newsvine Add to Technorati Add it to Google Bookmarks
comment
Santhiago Alves
2010-08-20 16:44:50

TI

This is just a quick note for those stuck with mysql error 145. Usually in these circumstances, MySQL will start just fine, the mysql> prompt will work, but attempts to read a particular table fail with error 145. This is usually a sign of a corrupted table. One common cause of this is the disk hitting 100%, so use df and du -sk / to try and figure out where your clogs are.

Once you're happy that the disk is okay, return to the mysql> prompt and run the following: check table table_name; where table_name is the name of your corrupted table. This may or may not fix the problem. This is basically the equivalent to running myisamchk, but without the range of options available with the full application.

Once again, you might find that you are still unable to access your table.MYI (that's the file which actually stores the information for the table). Your last resort is to exit mysql and run myisamchk from your shell prompt, passing in the 'recover' option. This can fix just about any MyISAM corruption and is done as follows:

/usr/bin/myisamchk -r /var/lib/mysql/database_name/table_name.MYI

Note that you may need to change those paths to point to your copy of myisamchk and your data directory. use 'find' and 'locate' to determin where they are on your system.

myisamchk -r is the most useful of all tools to the MySQL DBA in disaster recovery situations and has saved my skin on numerous occasions in the past..

christo





Thank's this solve my problem !
reply icon
chris
2010-10-25 23:35:47

It is worth also pointing out the -o option to myisamchk. The man page states:


  -o, --safe-recover  Uses old recovery method; Slower than '-r' but can
		      handle a couple of cases where '-r' reports that it
		      can't fix the data file.




reply icon
Libin V Babu
2011-12-06 10:09:20

Quick fix for #145 mysql error

Hey check the below link. It will explain how to solve this #145 mysql error.
http://libinvbabu.blogspot.com/2011/12/where-is-my-blog-145-mysql-error.html
reply icon