Record the use of myisamchk and mysqlcheck to repair damaged MySQL databases

Among the databases we use, the MYSQL database should be used more frequently. After all, there are many documents and scenarios provided. However, there is also the problem of database corruption. Here we can use myisamchk and mysqlcheck to repair the damaged MySQL database.

For example, if there is a problem with the database in our website directory, we can repair the database directory through the command. However, it needs to be backed up before repairing the database.

Find the bin/myisamchk tool in the installation directory of MySQL, and enter:

 myisamchk -c -r ../data/dedecmsv4/dede_archives.MYI

Then the myisamchk tool will help you recover the index of the data table. Restart MySQL. The problem is solved.

In general, you can use the myisamchk tool or mysqlcheck tool to repair the MySQL database:

Myisamchk repair tool

To use myisamchk, you must temporarily stop the MySQL server. For example, we want to troubleshoot the discuz database. Do the following:

 #Service MySQL stop; #Myisamchk - r/Absolute path of database file/* MYI # service mysql start

Myisamchk will automatically check and fix the index errors in the data table.

MySQL check repair tool

MySQL can be hot repaired without stopping MySQL. The operation steps are as follows:

 # mysqlcheck -r discuz.* #Service MySQL stop; #Myisamchk - r/Absolute path of database file/* MYI # service mysql start

Myisamchk will automatically check and fix the index errors in the data table.

Note: Whether it is myisamchk or mysqlcheck, generally do not use - f to force repair. The - f parameter will delete some error data to try to repair when the general repair fails.

Source: Lao Jiang Tribe » Record the use of myisamchk and mysqlcheck to repair damaged MySQL databases |Welcome to share (public account: Chiang's circle of friends)

Get new information from webmaster/add QQ group from the public account "Chiang Kai shek's circle of friends"【 one billion twelve million four hundred and twenty-three thousand two hundred and seventy-nine 】Get preferential promotion from merchants