<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="symbolic-links-to-databases">
      </a>
      10.12.2.1 Using Symbolic Links for Databases on Unix
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045222476128">
  </a>
  <a class="indexterm" name="idm46045222474640">
  </a>
  <p>
   On Unix, symlink a database using this procedure:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Create the database using
      <a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
       <code class="literal">
        CREATE
              DATABASE
       </code>
      </a>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa57836518"><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">CREATE</span> <span class="token keyword">DATABASE</span> mydb1<span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      Using
      <a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
       <code class="literal">
        CREATE DATABASE
       </code>
      </a>
      creates the database in the MySQL data directory and
              permits the server to update the data dictionary with
              information about the database directory.
     </p>
    </li>
    <li class="listitem">
     <p>
      Stop the server to ensure that no activity occurs in the
              new database while it is being moved.
     </p>
    </li>
    <li class="listitem">
     <p>
      Move the database directory to some disk where you have
              free space. For example, use
      <span class="command">
       <strong>
        tar
       </strong>
      </span>
      or
      <span class="command">
       <strong>
        mv
       </strong>
      </span>
      . If you use a method that copies
              rather than moves the database directory, remove the
              original database directory after copying it.
     </p>
    </li>
    <li class="listitem">
     <p>
      Create a soft link in the data directory to the moved
              database directory:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa51139218"><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">ln</span> <span class="token property">-s</span> <em class="replaceable">/path/to/mydb1</em> <em class="replaceable">/path/to/datadir</em></code></pre>
     </div>
     <p>
      The command creates a symlink named
      <code class="filename">
       mydb1
      </code>
      in the data directory.
     </p>
    </li>
    <li class="listitem">
     <p>
      Restart the server.
     </p>
    </li>
   </ol>
  </div>
 </div>
 <br/>
</div>
