在 mysql 上壞 table

 

個案1:

mysql> select * from xxx_zone;

見到資料

mysql> select * from xxx_zone where Zid="SYS"

見不到資料

mysql> select * from xxx_zone where Zid like "%SYS";

見到資料

mysql> select * from xxx_zone where trim(Zid)="SYS"

見到資料

解決:

REPAIR TABLE  xxx_zone EXTENDED

+-----------------------------+--------+----------+-----------------------------------------------------+
| Table                       | Op     | Msg_type | Msg_text                                            |
+-----------------------------+--------+----------+-----------------------------------------------------+
| DB.xxx_zone | repair | warning  | Duplicate key for record at 36 against record at 0  |
| DB.xxx_zone | repair | warning  | Duplicate key for record at 68 against record at 0  |
| DB.xxx_zone | repair | warning  | Duplicate key for record at 140 against record at 0 |
| DB.xxx_zone | repair | warning  | Number of rows changed from 5 to 2                  |
| DB.xxx_zone | repair | status   | OK                                                  |
+-----------------------------+--------+----------+-----------------------------------------------------+
5 rows in set (0.02 sec)

P.S.

一定要原整 Backup 先 !! 因為我試過 repair 後無左 record !!


 

個案2:

行以下 cmd 很久仍不能修復完

mysqlcheck -f -r -B drupal -p

解決:

show create table sessions;

CREATE TABLE `sessions` (
  `uid` int(10) unsigned NOT NULL,
  `sid` varchar(64) NOT NULL DEFAULT '',
  `hostname` varchar(128) NOT NULL DEFAULT '',
  `timestamp` int(11) NOT NULL DEFAULT '0',
  `cache` int(11) NOT NULL DEFAULT '0',
  `session` longtext,
  PRIMARY KEY (`sid`),
  KEY `uid` (`uid`),
  KEY `timestamp` (`timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

drop table sessions

 

 

 

 

Creative Commons license icon Creative Commons license icon