<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="corrupted-myisam-tables">
      </a>
      18.2.4.1 Corrupted MyISAM Tables
     </h4>
    </div>
   </div>
  </div>
  <p>
   Even though the
   <code class="literal">
    MyISAM
   </code>
   table format is very
        reliable (all changes to a table made by an SQL statement are
        written before the statement returns), you can still get
        corrupted tables if any of the following events occur:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      process is killed in the
            middle of a write.
     </p>
    </li>
    <li class="listitem">
     <p>
      An unexpected computer shutdown occurs (for example, the
            computer is turned off).
     </p>
    </li>
    <li class="listitem">
     <p>
      Hardware failures.
     </p>
    </li>
    <li class="listitem">
     <p>
      You are using an external program (such as
      <a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
       <span class="command">
        <strong>
         myisamchk
        </strong>
       </span>
      </a>
      ) to modify a table that is
            being modified by the server at the same time.
     </p>
    </li>
    <li class="listitem">
     <p>
      A software bug in the MySQL or
      <code class="literal">
       MyISAM
      </code>
      code.
     </p>
    </li>
   </ul>
  </div>
  <p>
   Typical symptoms of a corrupt table are:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      You get the following error while selecting data from the
            table:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa87936792"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Incorrect key file for table: '...'. Try to repair it</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Queries don't find rows in the table or return incomplete
            results.
     </p>
    </li>
   </ul>
  </div>
  <p>
   You can check the health of a
   <code class="literal">
    MyISAM
   </code>
   table
        using the
   <a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
    <code class="literal">
     CHECK TABLE
    </code>
   </a>
   statement,
        and repair a corrupted
   <code class="literal">
    MyISAM
   </code>
   table with
   <a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
    <code class="literal">
     REPAIR TABLE
    </code>
   </a>
   . When
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   is not running, you can also check or
        repair a table with the
   <a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
    <span class="command">
     <strong>
      myisamchk
     </strong>
    </span>
   </a>
   command.
        See
   <a class="xref" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
    Section 15.7.3.2, “CHECK TABLE Statement”
   </a>
   ,
   <a class="xref" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
    Section 15.7.3.5, “REPAIR TABLE Statement”
   </a>
   , and
   <a class="xref" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
    Section 6.6.4, “myisamchk — MyISAM Table-Maintenance Utility”
   </a>
   .
  </p>
  <p>
   If your tables become corrupted frequently, you should try to
        determine why this is happening. The most important thing to
        know is whether the table became corrupted as a result of an
        unexpected server exit. You can verify this easily by looking
        for a recent
   <code class="literal">
    restarted mysqld
   </code>
   message in the
        error log. If there is such a message, it is likely that table
        corruption is a result of the server dying. Otherwise,
        corruption may have occurred during normal operation. This is a
        bug. You should try to create a reproducible test case that
        demonstrates the problem. See
   <a class="xref" href="crashing.html" title="B.3.3.3 What to Do If MySQL Keeps Crashing">
    Section B.3.3.3, “What to Do If MySQL Keeps Crashing”
   </a>
   , and
   <a class="xref" href="debugging-mysql.html" title="7.9 Debugging MySQL">
    Section 7.9, “Debugging MySQL”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
