In windows, mysql may encounter the prompt "Incorrectkeyfilefortable: trytoreeffecrit". Common Causes of mysql table destruction: 1. Data File Corruption caused by sudden server power failure. 2. Force Shutdown without shutting down the mysql service first.
In windows, you may encounter the prompt "Incorrect key file for table: Try to repair it" in mysql. The common causes of mysql table destruction are as follows: 1. Data file damage caused by sudden server power failure. 2. Force Shutdown without shutting down the mysql service first.
Symptoms of damage
Typical symptoms of a damaged table are as follows:
1. When selecting data from a table, you get the following error: Incorrect key file for table: '...'. Try to repair it
2. the query cannot find rows in the table or return incomplete data.
3. Error: Table 'P' is marked as crashed and shoshould be retried red.
4. failed to open the table: Can't open file: '×××. myi' (errno: 145 ).
Repair of MySQL table corruption
To fix the MyISAM table, follow these steps:
1. Use reapair table or myisamchk to fix the issue.
After repairing the table with phpmyadmin, the system prompts "marked as crashed and last (automatic) repair failed ". After checking relevant information, I learned that myisamchk can be used to repair the table.
Myisamchk.exeis in the mysqlbindirectory. If this directory does not exist, download the attachment myisamchk.rar.
To check the error of a table, you only need to run myisamchk (in the bin directory of MySQL) and provide the file location and table name, or the index file name of the table:
The Code is as follows: |
|
Myisamchk/usr/local/mysql/var/dbName/tblName Myisamchk/usr/local/mysql/var/dbName/tblName. MYI |
You can run the preceding two commands to check the specified table. To check all tables in the database, you can use wildcards.
Repair procedure:
1) Stop the mysql service before the fix.
2) Open the command line and enter the/bin directory of mysql.
3) execute myisamchk -- the path of the recover database/*. MYI. Note: Do not follow the prompt; No.
However, the Myisamchk tool is not omnipotent. This tool is useless for some extreme damage, such as damage to the table description file. For this reason, the database administrator still needs the best routine backup of the database.
Use phpmyadmin to modify
Find the database of the problematic table in phpmyadmin, then find the problematic table, and click repair table below to solve the problem quickly.