Friday, October 2, 2015

MYSQL Table is marked as crashed - HOWTO

Today I found a:

"mysqldump: Got error: 145: Table is marked as crashed and should be repaired when using LOCK TABLES"

Just do this:


1.-Log into Mysql:

[root@webapp html]# mysql -uroot -p

2.-Change to DB with the issue:
mysql> use LiveDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

3.-Check and repair:
mysql> check table bad_table;
+-------------------------------+-------+----------+-----------------------------                                                         --------------------------+
| Table                         | Op    | Msg_type | Msg_text                                                                                                       |
+-------------------------------+-------+----------+-----------------------------                                                         --------------------------+
| LiveDB.bad_table | check | warning  | Table is marked as crashed                                                                                     |
| LiveDB.bad_table | check | error    | Size of datafile is: 507904                                                                  Should be: 507968 |
| LiveDB.bad_table | check | error    | Corrupt                                                                                                        |
+-------------------------------+-------+----------+-----------------------------                                                         --------------------------+
3 rows in set (0.00 sec)

mysql> repair table bad_table;
+-------------------------------+--------+----------+----------+
| Table                         | Op     | Msg_type | Msg_text |
+-------------------------------+--------+----------+----------+
| LiveDB.bad_table | repair | status   | OK       |
+-------------------------------+--------+----------+----------+
1 row in set (0.18 sec)

mysql> quit;

No comments:

Post a Comment