<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="reproducible-test-case">
      </a>
      7.9.1.7 Making a Test Case If You Experience Table Corruption
     </h4>
    </div>
   </div>
  </div>
  <p>
   The following procedure applies to
   <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
    <code class="literal">
     MyISAM
    </code>
   </a>
   tables. For information
        about steps to take when encountering
   <code class="literal">
    InnoDB
   </code>
   table corruption, see
   <a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
    Section 1.6, “How to Report Bugs or Problems”
   </a>
   .
  </p>
  <p>
   If you encounter corrupted
   <a class="link" href="myisam-storage-engine.html" title="18.2 The MyISAM Storage Engine">
    <code class="literal">
     MyISAM
    </code>
   </a>
   tables or if
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   always fails after some
        update statements, you can test whether the issue is
        reproducible by doing the following:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Stop the MySQL daemon with
      <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
       <span class="command">
        <strong>
         mysqladmin
            shutdown
        </strong>
       </span>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Make a backup of the tables to guard against the very
            unlikely case that the repair does something bad.
     </p>
    </li>
    <li class="listitem">
     <p>
      Check all tables with
      <a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
       <span class="command">
        <strong>
         myisamchk -s
            database/*.MYI
        </strong>
       </span>
      </a>
      . Repair any corrupted tables with
      <a class="link" href="myisamchk.html" title="6.6.4 myisamchk — MyISAM Table-Maintenance Utility">
       <span class="command">
        <strong>
         myisamchk -r
            database/
         <em class="replaceable">
          <code>
           table
          </code>
         </em>
         .MYI
        </strong>
       </span>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Make a second backup of the tables.
     </p>
    </li>
    <li class="listitem">
     <p>
      Remove (or move away) any old log files from the MySQL data
            directory if you need more space.
     </p>
    </li>
    <li class="listitem">
     <p>
      Start
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      with the binary log enabled.
            If you want to find a statement that crashes
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      , you should start the server with
            the general query log enabled as well. See
      <a class="xref" href="query-log.html" title="7.4.3 The General Query Log">
       Section 7.4.3, “The General Query Log”
      </a>
      , and
      <a class="xref" href="binary-log.html" title="7.4.4 The Binary Log">
       Section 7.4.4, “The Binary Log”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      When you have gotten a crashed table, stop the
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server.
     </p>
    </li>
    <li class="listitem">
     <p>
      Restore the backup.
     </p>
    </li>
    <li class="listitem">
     <p>
      Restart the
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      server
      <span class="emphasis">
       <em>
        without
       </em>
      </span>
      the binary log enabled.
     </p>
    </li>
    <li class="listitem">
     <p>
      Re-execute the statements with
      <a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
       <span class="command">
        <strong>
         mysqlbinlog
            binary-log-file | mysql
        </strong>
       </span>
      </a>
      . The binary log is saved
            in the MySQL database directory with the name
      <code class="literal">
       hostname-bin.
       <em class="replaceable">
        <code>
         NNNNNN
        </code>
       </em>
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If the tables are corrupted again or you can get
      <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
       <span class="command">
        <strong>
         mysqld
        </strong>
       </span>
      </a>
      to die with the above command, you
            have found a reproducible bug. FTP the tables and the binary
            log to our bugs database using the instructions given in
      <a class="xref" href="bug-reports.html" title="1.6 How to Report Bugs or Problems">
       Section 1.6, “How to Report Bugs or Problems”
      </a>
      . If you are a support
            customer, you can use the MySQL Customer Support Center
            (
      <a class="ulink" href="https://www.mysql.com/support/" target="_blank">
       https://www.mysql.com/support/
      </a>
      ) to alert the MySQL team
            about the problem and have it fixed as soon as possible.
     </p>
    </li>
   </ol>
  </div>
 </div>
 <br/>
</div>
