This article mainly describes how to correctly repair damaged MySQL Data Tables. We all know that power failure or abnormal shutdown may lead to MySQL (the best combination with PHP) database Error. There are two main methods: one is to use MySQL (the best combination with PHP) checktable and repairtable SQL
This article mainly describes how to correctly repair damaged MySQL Data Tables. We all know that power failure or abnormal shutdown may lead to MySQL (the best combination with PHP) database Error. There are two main methods: one is to use MySQL (the best combination with PHP) check table and repair table SQL
This article mainly describes how to correctly repair damaged MySQL Data Tables. We all know that power failure or abnormal shutdown may lead to MySQL (the best combination with PHP) database Error. There are two main methods:
One method is to use the SQL statement of check table and repair table of MySQL (the best combination with PHP), and the other method is to use MySQL (the best combination with PHP) provides multiple myisamchk and isamchk Data Detection and recovery tools. The former is easy to use. Recommended.
1. check table and repair table
Log on to the MySQL (best combination with PHP) terminal:
MySQL (best combination with PHP)-uxxxxx-p dbname
> Check table tabTest;
If the Status is OK, you do not need to fix it. If there is an Error, you can use:
> Repair table tabTest;
After the repair, you can use the check table command to perform the check. You can also use the check/repair function in the new phpMyAdmin version.
2. myisamchk, isamchk
Here, myisamchk applies to MYISAM data tables, while isamchk applies to ISAM-type MySQL Data Tables. The main parameters of these two commands are the same. Generally, new systems use MYISAM as the default data table type. Here we use myisamchk as an example. When a problem occurs in a data table, you can use:
Myisamchk tablename. MYI
To fix the issue, use:
Myisamchk-of tablename. MYI
For detailed parameter descriptions of myisamchk, see its help. Make sure that the MySQL (the best combination with PHP) server does not access this MySQL Data Table during modification, it is safe to shut down the MySQL (the best combination with PHP) server during the detection.
In addition, you can place the following command in your rc. local to start the MySQL (the best combination with PHP) server:
[-X/tmp/MySQL (the best combination with PHP). sock] &/pathtochk/myisamchk-of/DATA_DIR/*. MYI
The/tmp/MySQL (the best combination with PHP ). sock is the location of the Sock file listened by MySQL (the best combination with PHP). For users who use RPM to install it, it should be/var/lib/MySQL (the best combination with PHP) /MySQL (the best combination with PHP ). sock, for source code installation, it is/tmp/MySQL (the best combination with PHP ). sock can be changed based on actual conditions, while pathtochk is the location where myisamchk is located, and DATA_DIR is the location where your MySQL (best combination with PHP) database is stored.
Note that if you plan to place this command in your rc. local, you must make sure that the MySQL (best combination with PHP) server is not started when you execute this command!
Detection and repair of all databases (tables)
MySQL (the best combination with PHP) check-A-o-r-p
The above content is an introduction to how to repair damaged MySQL Data Tables. I hope you will have some gains.