解决方法:
1、登陆mysql数据库
[root@MySQL ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 74316
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| LOG |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use LOG
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
mysql> show tables;
+----------------+
| Tables_in_LOG |
+----------------+
| PUBLISHURL |
| PUBLISHURL_NEW |
+----------------+
2 rows in set (0.00 sec)
2、检查表的健康状况
mysql> check table PUBLISHURL_NEW;
+--------------------+-------+----------+----------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------------+-------+----------+----------------------------------------------------------+
| LOG.PUBLISHURL_NEW | check | warning | Table is marked as crashed |
| LOG.PUBLISHURL_NEW | check | warning | 2 clients are using or haven't closed the table properly |
| LOG.PUBLISHURL_NEW | check | error | Can't read key from filepos: 7356416 |
| LOG.PUBLISHURL_NEW | check | error | Corrupt |
+--------------------+-------+----------+----------------------------------------------------------+
4 rows in set, 1 warning (0.15 sec)
mysql> exit
Bye
3、由于有程序在使用,关闭数据库断开连接,对于生产库不建议这样做
[root@MySQL ~]# service mysqld restart;
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[root@MySQL ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use LOG
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
4、检查完成
mysql> check table PUBLISHURL_NEW;
+--------------------+-------+----------+--------------------------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------------+-------+----------+--------------------------------------------------------------------------+
| LOG.PUBLISHURL_NEW | check | error | Table './LOG/PUBLISHURL_NEW' is marked as crashed and should be repaired |
+--------------------+-------+----------+--------------------------------------------------------------------------+
1 row in set (0.00 sec)
5、修复成功
mysql> repair table PUBLISHURL_NEW;
+--------------------+--------+----------+-------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------------+--------+----------+-------------------------------------------------+
| LOG.PUBLISHURL_NEW | repair | info | Wrong bytesec: 0- 0- 0 at 24324356; Skipped |
| LOG.PUBLISHURL_NEW | repair | warning | Number of rows changed from 166555 to 166462 |
| LOG.PUBLISHURL_NEW | repair | status | OK |
+--------------------+--------+----------+-------------------------------------------------+
3 rows in set (3.67 sec)
6、检查修复后的结果,大功告成
mysql> check table PUBLISHURL_NEW;
+--------------------+-------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+--------------------+-------+----------+----------+
| LOG.PUBLISHURL_NEW | check | status | OK |
+--------------------+-------+----------+----------+
1 row in set (0.67 sec)
mysql>