id=164 the MySQL database error is a very common problem due to a power outage or an abnormal shutdown. There are two ways to use MySQL's check table and Repair table SQL statement, and the other is to use the multiple myisamchk provided by MySQL to isamchk the data detection recovery tool. The former is relatively simple to use. Recommended use.
1. Check table and Repair table
Log in to MySQL terminal:
Mysql-uxxxxx-p dbname
> Check table tabtest;
If the result says status is OK, then do not repair, if there is error, you can use:
> Repair table tabtest;
Fixed and can be checked using the Check Table command after the repair. You can also use the Check/repair feature in the new version of phpMyAdmin.
2. Myisamchk, Isamchk
Where myisamchk applies to data tables of the MyISAM type, and ISAMCHK applies to data tables of the ISAM type. The main parameters of these two commands are the same, and generally the new system uses MyISAM as the default data table type, which is illustrated with Myisamchk as an example. When you find a problem with a data table, you can use:
MYISAMCHK TableName. MYI
For testing, if needed, you can use:
MYISAMCHK-OF TableName. MYI
For a detailed parameter description of the MYISAMCHK, refer to its use Help. Note that when making modifications, you must make sure that the MySQL server does not have access to the data sheet, and that it is best to shutdown the MySQL server in case of an inspection.
-----------------------------
Alternatively, you can put the following command in your rc.local before starting the MySQL server:
[-x/tmp/mysql.sock] &&/pathtochk/myisamchk-of/data_dir/*/*. MYI
The/tmp/mysql.sock is the sock file location of the MySQL listener, for users who use RPM installation should be/var/lib/mysql/mysql.sock, for the use of the source installation is/tmp/ Mysql.sock can be changed according to their actual situation, and Pathtochk is Myisamchk location, Data_dir is your MySQL database storage location.
Note that if you intend to place this command in your rc.local, you must confirm that the MySQL server must not be started when executing this instruction! Detect and repair all databases (tables)
How to repair a corrupted MySQL data sheet