Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991

Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993
Question 78: How do you repair this table? – MySQL Question of the Day

Skip to content

By plogi in mysql questions

Again, we’ll create and then break a table. Follow the instructions below:
 

drop table if exists t1;
create table t1 (tid bigint not null auto_increment,
                 ttype int,
                 tsum double,
                 tdate date,
                 primary key (tid),index(ttype,tdate))
engine=myisam;
insert into t1 select null,rand()*99999999,floor(rand()*3),
         adddate('2010-01-01',interval rand()*360 day)
  from information_schema.columns,
       information_schema.tables limit 40000 ;
flush tables;

select concat(@@global.datadir,database()) as dbdir;

While keeping the mysql session open, go to the dbdir directory and delete t1.MYI .
In the mysql session, issue a “check table t1;”
you should see something like this:

MariaDB [tt]> check table t1;
+-------+-------+----------+----------------------------------+
| Table | Op    | Msg_type | Msg_text                         |
+-------+-------+----------+----------------------------------+
| tt.t1 | check | Error    | Can't find file: 't1' (errno: 2) |
| tt.t1 | check | status   | Operation failed                 |
+-------+-------+----------+----------------------------------+
2 rows in set (0.00 sec)


 
Note, that a “REPAIR TABLE t1;” will not repair the table this time (try it!).
Pick from the options below everything that needs to be done in order to repair this table.

a) mysqladmin -p -u root shutdown
b) repair table t1 index_rebuild;
c) repair table t1 use_frm;
d) repair table t1 extended;
e) repair table t1 quick;

 
[MyISAM table maintenance - Investigate and repair broken tables]

Tags: , ,

Comment Feed

One Response

  1. plogi7. July 2010 @ 20:11:17


    c

    Only the “USE_FRM” option of the REPAIR will help you now.
    Use this option only as a last resort.
    Afterwards, use “SHOW TABLE STATUS” to check the amount of rows and the auto_increment.
    If necessary, adjust the value with “ALTER TABLE t1 AUTO_INCREMENT=“.
    As with any REPAIR, make a copy of the table-files first – so that you have something left, in case the REPAIR emtpies your table.

You must be logged in to post a comment.