<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="reloading-delimited-text-dumps">
      </a>
      9.4.4 Reloading Delimited-Text Format Backups
     </h3>
    </div>
   </div>
  </div>
  <p>
   For backups produced with
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump --tab
     </strong>
    </span>
   </a>
   ,
        each table is represented in the output directory by an
   <code class="filename">
    .sql
   </code>
   file containing the
   <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
    <code class="literal">
     CREATE TABLE
    </code>
   </a>
   statement for the
        table, and a
   <code class="filename">
    .txt
   </code>
   file containing the table
        data. To reload a table, first change location into the output
        directory. Then process the
   <code class="filename">
    .sql
   </code>
   file with
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   to create an empty table and process
        the
   <code class="filename">
    .txt
   </code>
   file to load the data into the
        table:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa22645829"><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-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysql</span> db1 &lt; t1<span class="token punctuation">.</span>sql
<span class="token prompt">$&gt; </span><span class="token command">mysqlimport</span> db1 t1<span class="token punctuation">.</span>txt</code></pre>
  </div>
  <p>
   An alternative to using
   <a class="link" href="mysqlimport.html" title="6.5.5 mysqlimport — A Data Import Program">
    <span class="command">
     <strong>
      mysqlimport
     </strong>
    </span>
   </a>
   to load
        the data file is to use the
   <a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
    <code class="literal">
     LOAD
        DATA
    </code>
   </a>
   statement from within the
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   client:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa71261435"><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-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> db1<span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">LOAD</span> <span class="token keyword">DATA</span> <span class="token keyword">INFILE</span> <span class="token string">'t1.txt'</span> <span class="token keyword">INTO</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   If you used any data-formatting options with
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump
     </strong>
    </span>
   </a>
   when you initially dumped the
        table, you must use the same options with
   <a class="link" href="mysqlimport.html" title="6.5.5 mysqlimport — A Data Import Program">
    <span class="command">
     <strong>
      mysqlimport
     </strong>
    </span>
   </a>
   or
   <a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
    <code class="literal">
     LOAD
        DATA
    </code>
   </a>
   to ensure proper interpretation of the data file
        contents:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa26501356"><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-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysqlimport</span> <span class="token constant">--fields-terminated-by</span><span class="token attr-value"><span class="token punctuation">=</span>,</span>
         <span class="token constant">--fields-enclosed-by</span>=<span class="token atrule">'"'</span> <span class="token constant">--lines-terminated-by</span><span class="token attr-value"><span class="token punctuation">=</span>0x0d0a</span> db1 t1<span class="token punctuation">.</span>txt</code></pre>
  </div>
  <p>
   Or:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa64954929"><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-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">USE</span> db1<span class="token punctuation">;</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">LOAD</span> <span class="token keyword">DATA</span> <span class="token keyword">INFILE</span> <span class="token string">'t1.txt'</span> <span class="token keyword">INTO</span> <span class="token keyword">TABLE</span> t1
       <span class="token keyword">FIELDS</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">','</span> <span class="token keyword">FIELDS</span> <span class="token keyword">ENCLOSED</span> <span class="token keyword">BY</span> <span class="token string">'"'</span>
       <span class="token keyword">LINES</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">'\r\n'</span><span class="token punctuation">;</span></code></pre>
  </div>
 </div>
 <br/>
</div>
