After using MySQL for a long time, some problems may occur in the database. Most problems can be solved quickly through simple operations. The following describes two methods to quickly repair the MySQL database.
After using MySQL for a long time, some problems may occur in the database. Most problems can be solved quickly through simple operations. The following describes two methods to quickly repair the MySQL database.
1. myisamchk
To use myisamchk, you must temporarily stop the MySQL server. For example, we want to repair the discuz database. Perform the following operations:
# Service mysql stop (stop MySQL );
# Myisamchk-r/absolute path of the database file/* MYI
# Service mysql start
Myisamchk automatically checks and fixes index errors in the data table.
2. mysqlcheck
You can use mysqlcheck to perform hotfix without stopping MySQL. The procedure is as follows:
# Mysqlcheck-r discuz .*
# Service mysql stop (stop MySQL );
# Myisamchk-r/absolute path of the database file/* MYI
# Service mysql start
Myisamchk automatically checks and fixes index errors in the data table.
Note: Do not use-f to forcibly fix myisamchk or mysqlcheck. If the-f parameter fails to be repaired, delete some data with errors to try to fix it. Therefore, do not use-f unless necessary.