Quick fix of damaged MySQL database

  • 2020-05-10 23:03:51
  • OfStack

1, myisamchk
You must temporarily stop the MySQL server to use myisamchk. For example, we are going to overhaul the discuz database. Do the following:
# service mysql stop (stop MySQL);
# myisamchk -r/absolute path to the database file /*MYI
# service mysql start
myisamchk automatically checks and fixes index errors in the data table.
2, mysqlcheck
With mysqlcheck, you don't need to stop MySQL. You can do a hot fix. The operation steps are as follows:
# mysqlcheck -r discuz.*

# service mysql stop (stop MySQL);
# myisamchk - absolute path to r/database file /*MYI
# service mysql start
myisamchk automatically checks and fixes index errors in the data table.

Note that for either myisamchk or mysqlcheck, do not use -f to force a fix in the case of 1, the -f parameter will delete some of the error data to try to fix if the 1 fix fails. So don't use -f unless you have to.


Related articles: