Repairing corrupted mysql databases when they get corrupted can happen in many situations. When your databases get corrupted there are plenty of tools available to repair them.
In most cases only the index gets corrupted and not the actual data which is very rare to happen.
In this article we will demostrate myisamchk tool to repair some corrupted mysql databases as well mysqlcheck and repair table command.
Locate mysql databases:
cd /var/lib/mysql
myisamchk Utility (MyISAM Only)
Description: myisamchk can check and repair MyISAM tables
Running the repair command for all database tables:
myisamchk -q -r -f -s *.MYI
Running the repair command for specific table:
myisamchk -q -r -f -s table.MYI
Options used:
Change the collation used by the index.
-q, –quick Faster repair by not modifying the data file. One can give a second ‘-q’ to force myisamchk to modify the original datafile in case of duplicate keys.
NOTE: Tables where the data file is corrupted can’t be fixed with this option.-r, –recover Can fix almost anything except unique keys that aren’t unique.
-f, –force Overwrite old temporary files.
-s, –silent Only print errors. One can use two -s to make myisamchk very silent.
Other database repair tools:
REPAIR Table SQL Statement (MyISAM Only)
Usage:
mysql> REPAIR TABLE tablename;
In case the indexing file is missing or is corrupted u can use the USE_FRM option.
mysql> REPAIR TABLE tablename USE_FRM;
mysqlcheck Utility (MyISAM Only)
Usage:
mysqlcheck -r database table -uuser -ppass



















































Wildhorsend





