Repair of MySQL Data Tables (corrupted)

Source: Internet
Author: User
The following articles mainly describe how to correctly repair corrupted MySQL Data Tables. There are two methods: checktable and repairtable, and myisamchk and isamchk, mySQL (the best combination with PHP) database errors caused by power failure or abnormal shutdown are very common problems. There are two methods:

The following articles mainly describe how to correctly repair corrupted MySQL Data Tables. One is check table and repair table, and the other is through myisamchk, isamchk, mySQL (the best combination with PHP) database errors caused by power failure or abnormal shutdown are very common problems. There are two methods:

The following articles mainly describe how to correctly repair corrupted MySQL Data Tables. One is check table and repair table, and the other is through myisamchk, isamchk, mySQL (the best combination with PHP) database errors caused by power failure or abnormal shutdown are very common problems.

There are two ways to use the SQL statement of check table and repair table in MySQL (the best combination with PHP, another method is to use multiple myisamchk and isamchk Data Detection and recovery tools provided by MySQL (the best combination with PHP. 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

 
 
  1. > check table tabTest;

If the Status is OK, you do not need to fix it. If there is an Error, you can use:

 
 
  1. > 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 MySQL Data Tables of MYISAM type, while isamchk applies to data tables of ISAM type. 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 MySQL DATA table:

 
 
  1. myisamchk tablename.MYI

To fix the issue, use:

 
 
  1. 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:

 
 
  1. [-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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.