<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="clone-plugin-local">
      </a>
      7.6.7.2 Cloning Data Locally
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045255666704">
  </a>
  <p>
   The clone plugin supports the following syntax for cloning data
        locally; that is, cloning data from the local MySQL data
        directory to another directory on the same server or node where
        the MySQL server instance runs:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa42952767"><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 keyword">CLONE</span> <span class="token keyword">LOCAL</span> <span class="token keyword">DATA</span> <span class="token keyword">DIRECTORY</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token string">'<em class="replaceable">clone_dir</em>'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   To use
   <a class="link" href="clone.html" title="15.7.5 CLONE Statement">
    <code class="literal">
     CLONE
    </code>
   </a>
   syntax, the clone
        plugin must be installed. For installation instructions, see
   <a class="xref" href="clone-plugin-installation.html" title="7.6.7.1 Installing the Clone Plugin">
    Section 7.6.7.1, “Installing the Clone Plugin”
   </a>
   .
  </p>
  <p>
   The
   <a class="link" href="privileges-provided.html#priv_backup-admin">
    <code class="literal">
     BACKUP_ADMIN
    </code>
   </a>
   privilege is
        required to execute
   <a class="link" href="clone.html" title="15.7.5 CLONE Statement">
    <code class="literal">
     CLONE
        LOCAL DATA DIRECTORY
    </code>
   </a>
   statements.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa48760545"><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">GRANT</span> BACKUP_ADMIN <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token string">'<em class="replaceable">clone_user</em>'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   where
   <code class="literal">
    <em class="replaceable">
     <code>
      clone_user
     </code>
    </em>
   </code>
   is the MySQL user that performs the cloning operation. The user
        you select to perform the cloning operation can be any MySQL
        user with the
   <a class="link" href="privileges-provided.html#priv_backup-admin">
    <code class="literal">
     BACKUP_ADMIN
    </code>
   </a>
   privilege on *.*.
  </p>
  <p>
   The following example demonstrates cloning data locally:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa1510228"><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">CLONE</span> <span class="token keyword">LOCAL</span> <span class="token keyword">DATA</span> <span class="token keyword">DIRECTORY</span> <span class="token operator">=</span> <span class="token string">'<em class="replaceable">/path/to/clone_dir</em>'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   where
   <em class="replaceable">
    <code>
     /path/to/clone_dir
    </code>
   </em>
   is the full
        path of the local directory that data is cloned to. An absolute
        path is required, and the specified directory
        (
   <span class="quote">
    “
    <span class="quote">
     <em class="replaceable">
      <code>
       clone_dir
      </code>
     </em>
    </span>
    ”
   </span>
   ) must not
        exist, but the specified path must be an existent path. The
        MySQL server must have the necessary write access to create the
        directory.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    A local cloning operation does not support cloning of
          user-created tables or tablespaces that reside outside of the
          data directory. Attempting to clone such tables or tablespaces
          causes the following error:
    <span class="errortext">
     ERROR 1086 (HY000):
          File '
     <em class="replaceable">
      <code>
       /path/to/tablespace_name.ibd
      </code>
     </em>
     '
          already exists
    </span>
    . Cloning a tablespace with the same
          path as the source tablespace would cause a conflict and is
          therefore prohibited.
   </p>
   <p>
    All other user-created
    <code class="literal">
     InnoDB
    </code>
    tables and
          tablespaces, the
    <code class="literal">
     InnoDB
    </code>
    system tablespace,
          redo logs, and undo tablespaces are cloned to the specified
          directory.
   </p>
  </div>
  <p>
   If desired, you can start the MySQL server on the cloned
        directory after the cloning operation is complete.
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa49172545"><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">mysqld_safe</span> <span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">clone_dir</em></span></code></pre>
  </div>
  <p>
   where
   <em class="replaceable">
    <code>
     clone_dir
    </code>
   </em>
   is the directory that
        data was cloned to.
  </p>
  <p>
   For information about monitoring cloning operation status and
        progress, see
   <a class="xref" href="clone-plugin-monitoring.html" title="7.6.7.10 Monitoring Cloning Operations">
    Section 7.6.7.10, “Monitoring Cloning Operations”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
