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 | + --------------- + ------- + ---------- + |