mysql>
REPAIR TABLE music.artist;+--------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+--------------+--------+----------+----------+
| music.artist | repair | status | OK |
+--------------+--------+----------+----------+
1 row inset sec)
If the music database was previously selected with the USE music command, you can write artist instead of music.artist
The mysqlcheck and mysqlisamchk programs allow you to check and repair tables from the command line.
mysqlcheckmysqlcheck allows you to check and repair tables from the command line.
In practice,
the most important options you’ll need are:
all-databases
Performs operation on all tables in all databases on the server.
repair
Tries to repair any corrupted tables.
extended
Tries harder to repair any corrupted tables (slower than just repair
).
For example, to check and repair all
tables in the music database,
you would write mysqlcheck --user=root --password=the_mysql_root_password -repair musicmusic.album OK
music.artist warning : Number of rows changed from 1 to status : OK
music.played OK
music.track OK
To check and attempt to repair all databases on the server, you would write
mysqlcheck --user=root --password=the_mysql_root_password -extended --all-databasesmyisamchkThis tool operates directly
on the MyISAM database files, and so does not require the server to be shutdown. However, you need to ensure that the server is not using the tables while you’re trying to repair them if you can’t stop queries to the server, it’s probably a good idea to shutdown the
server before using myisamchkTo use this utility, you need to specify the table or index file you want to check or repair.
For example, to check the artist
table in the music database, give the path to the
artist.MYI file:
Share with your friends: