[MySQL] Quick fix "is marked as crashed and should be repaired" fault

Source: Internet
Author: User
Tags phpmyadmin

The specific error is as follows:

Table '. \tablename\posts ' is marked as crashed and should be repaired

Note that the Forum post table posts is flagged with a problem and needs to be repaired. I remember having had similar problems before, but just click on the Repair button on phpMyAdmin to fix it automatically, but this time it's absolutely nothing. So get online and find out why. Eventually the problem is solved. Here's how to fix it:

Locate the Bin/myisamchk tool for the MySQL installation directory and enter it at the command line:

Myisamchk-c-R. /data/tablename/posts. MYI

Then the Myisamchk tool will help you recover the index of the data table. As if you don't have to restart MySQL, the problem is solved.

Problem Analysis:

1.
The cause of the error, some netizens said is frequently query and update the Dede_archives table caused by the index error, because my page is not static generation, but dynamic page, so I agree with this argument.
It is also said that the MySQL database has been damaged for some reason, such as: The database server burst power outage, in the database table provides services when the original file of the table to do some kind of operation can cause
The MySQL database table is corrupted and cannot read the data. This is because some of the unpredictable problems caused the damage to the table.


2. Problem solving method.

When you try to fix a corrupted table, there are three types of repair. If you get an error message stating that a temporary file cannot be established, delete the file indicated by the information and try again-this is usually left over from the last repair operation.
The three repair methods are as follows:
% Myisamchk--recover--quick/path/to/tblname
% Myisamchk--recover/path/to/tblname
% Myisamchk--safe-recover/path/to/tblname

The first is the quickest, which is used to fix the most common problems, and the last is the slowest one to fix problems that other methods cannot fix.

Checking and repairing MySQL data files
If the above method cannot fix a damaged table, you can try these two techniques before you give up:
Such as
The index file (*) of the table you suspect. MYI) An uncorrectable error has occurred, even if the file is lost, you can use the data file (*. MYD) and data Format files (*.FRM) re-reborn
Into it. First make a copy of the data file (TBLNAME.MYD). To restart your MySQL service and connect to the service, use the following command to delete the contents of the table:
Mysql> DELETE from Tblname;
In
When you delete the contents of a table, a new index file is created. Quit logging in and close the service again, and then overwrite the new (empty) data file with the data file (tblname.myd) you just saved.
Finally, using MYISAMCHK to perform a standard fix (the second method above), the index data is regenerated based on the contents of the table's data and the table's format file.

If your table's
Format file (tblname.frm) is missing or an uncorrectable error has occurred, but you know how to use the corresponding create
Table statement to regenerate this table, you can regenerate a new. frm file and and your data file and index file (if there is a problem with the index file, use the method above to rebuild a new one)
Use. First make a copy of the data and index file, and then delete the original file (delete all the records about the table in the Data directory).

Start the MySQL service and create a new table using the original CREATE table file. The new. frm file should work correctly, but it's a good idea to perform a standard fix (the second method above).

In order not to make a bold fix, so take a conservative approach, we know that MySQL an efficient management tool is PhpMyAdmin, and in the management software contains the inspection, analysis, repair, optimization functions, compared to the vague command line provided by the Internet more secure and easy.

Through the practice, after using the checklist function did find the problem, and then repaired with the repair function, the feedback results each table is OK, and then perform an optimization, re-test access to the site finally resumed normal. A disaster to avoid ...

(In fact, the table is hung, restore the backup is possible)

[MySQL] Quick fix "is marked as crashed and should be repaired" fault

Related Article

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.