Fix MySQL MyISAM table command check table usage

Source: Internet
Author: User

The following error occurs in the MySQL log file. crash does not occur in the MySQL table. It is generally caused by stopping MySQL when the database is updated.

Check table syntax

Check table tbl_name [, tbl_name]... [option]...
Option = {QUICK | FAST | MEDIUM | EXTENDED | CHANGED}

Check whether one or more tables have errors. Check table is useful for MyISAM and InnoDB tables. For MyISAM tables, keyword statistics are updated.

Check table can also CHECK whether the view has an error. For example, the referenced TABLE in the view definition does not exist.
The check table statement returns a TABLE containing the following columns:

[Warning] Checking table: './database name/table name'
[ERROR] mysqld: Table'./database name/Table name' is marked as crashed and shoshould be retried Red

Run the "check table name;" command to confirm the error.

The code is as follows: Copy code

Mysql> check table name quick;

+ ------------------ + ------- + ---------- + ------------------------------------------------------------ +
| Table | Op | Msg_type | Msg_text |
+ ------------------ + ------- + ---------- + ------------------------------------------------------------ +
| DB. Table name | check | warning | Table is marked as crashed and last repair failed |
| DB. table name | check | warning | 1 client is using or hasn' t closed the table properly |
| DB. Table name | check | error | Size of datafile is: 268414976 shocould be: 268871480 |
| DB. Table name | check | error | invalid UPT |
+ ------------------ + ------- + ---------- + ------------------------------------------------------------ +

From the above results, we can see that the MySQL database is damaged.

Use the "repair table name;" command to fix the problem. Note that the repair table command can only be used for MyISAM tables.

The code is as follows: Copy code

Mysql> repair table name;
+ --------------- + -------- + ---------- + ---------------------------------------------------------- +
| Table | Op | Msg_type | Msg_text |
+ --------------- + -------- + ---------- + ---------------------------------------------------------- +
| DB. Table name | repair | info | Found block that points outside data file at 268414940 |
| DB. Table name | repair | warning | Number of rows changed from 4377692 to 4370359 |
| DB. Table name | repair | status | OK |
+ --------------- + -------- + ---------- + ---------------------------------------------------------- +

Run the check table command again.

The code is as follows: Copy code

Mysql> check table name quick;
+ --------------- + ------- + ---------- +
| Table | Op | Msg_type | Msg_text |
+ --------------- + ------- + ---------- +
| DB. Table name | check | status | OK |
+ --------------- + ------- + ---------- +

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.