2.4k questions

2.4k answers

96.2k users

9 Online Users
0 Member 9 Guest
Today Visits : 923
Yesterday Visits : 2628
Total Visits : 2363973

Categories

Notice

Dear All, These are my answers from Quora and primarily Google; please check the answer and from others sites; the answers are free and without any liability.To make a decision, write down all of the positives and negatives on a piece of paper.Thank you,

Elias Katsaniotis, MSc

Information

Viktoria Katsanioti,

Kaliningrad,

Russia,

matizegr@yahoo.com

0 votes
54 views

How do I repair MyISAM tables in MySQL?
in General by (46.5k points)

1 Answer

0 votes

First, try myisamchk -r -q tbl_name ( -r -q means “quick recovery mode”). This attempts to repair the index file without touching the data file. If the data file contains everything that it should and the delete links point at the correct locations within the data file, this should work, and the table is fixed.

please read

7.6.3 How to Repair MyISAM Tables
7.6.3 How to Repair MyISAM Tables The discussion in this section describes how to use myisamchk on MyISAM tables (extensions .MYI and .MYD ). You can also use the CHECK TABLE and REPAIR TABLE statements to check and repair MyISAM tables. See Section 13.7.2.2, “CHECK TABLE Statement” , and Section 13.7.2.5, “REPAIR TABLE Statement” . Symptoms of corrupted tables include queries that abort unexpectedly and observable errors such as these: tbl_name .frm is locked against change Can't find file tbl_name .MYI (Errcode: nnn ) Unexpected end of file Record file is crashed Got error nnn from table handler To get more information about the error, run perror nnn , where nnn is the error number. The following example shows how to use perror to find the meanings for the most common error numbers that indicate a problem with a table: $> perror 126 127 132 134 135 136 141 144 145 MySQL error code 126 = Index file is crashed MySQL error code 127 = Record-file is crashed MySQL error code 132 = Old database file MySQL error code 134 = Record was already deleted (or record file crashed) MySQL error code 135 = No more room in record file MySQL error code 136 = No more room in index file MySQL error code 141 = Duplicate unique key or constraint on write or update MySQL error code 144 = Table is crashed and last repair failed MySQL error code 145 = Table was marked as crashed and should be repaired Note that error 135 (no more room in record file) and error 136 (no more room in index file) are not errors that can be fixed by a simple repair. In this case, you must use ALTER TABLE to increase the MAX_ROWS and AVG_ROW_LENGTH table option values: ALTER TABLE tbl_name MAX_ROWS= xxx AVG_ROW_LENGTH= yyy ; If you do not know the current table option values, use SHOW CREATE TABLE . For the other errors, you must repair your tables. myisamchk can usually detect and fix most problems that occur. The repair process involves up to four stages, described here. Before you begin, you should change location to the database directory and check the permissions of the table files. On Unix, make sure that they are readable by the user that mysqld runs as (and to you, because you need to access the files you are checking). If it turns out you need to modify files, they must also be writable by you. This section is for the cases where a table check fails (such as those described in Section 7.6.2, “How to Check MyISAM Tables for Errors” ), or you want to use the extended features that myisamchk provides. The myisamchk options used for table maintenance with are described in Section 4.6.3, “myisamchk — MyISAM Table-Maintenance Utility” . myisamchk also has variables that you can set to control memory allocation that may improve performance. See Section 4.6.3.6, “myisamchk Memory Usage” . If you are going to repair a table from the command line, you
by (46.5k points)
...