<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="clone">
      </a>
      15.7.5 CLONE Statement
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045171624560">
  </a>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa71764669"><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> <em class="replaceable">clone_action</em>

<em class="replaceable">clone_action</em>: {
    <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>
  <span class="token operator">|</span> <span class="token keyword">INSTANCE</span> <span class="token keyword">FROM</span> <span class="token string">'<em class="replaceable">user</em>'</span>@<span class="token string">'<em class="replaceable">host</em>'</span>:<span class="token keyword"><em class="replaceable">port</em></span>
    <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'<em class="replaceable">password</em>'</span>
    <span class="token punctuation">[</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>
    <span class="token punctuation">[</span><span class="token keyword">REQUIRE</span> <span class="token punctuation">[</span><span class="token keyword">NO</span><span class="token punctuation">]</span> <span class="token keyword">SSL</span><span class="token punctuation">]</span>
}</code></pre>
  </div>
  <p>
   The
   <a class="link" href="clone.html" title="15.7.5 CLONE Statement">
    <code class="literal">
     CLONE
    </code>
   </a>
   statement is used to
      clone data locally or from a remote MySQL server instance. 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. See
   <a class="xref" href="clone-plugin.html" title="7.6.7 The Clone Plugin">
    Section 7.6.7, “The Clone Plugin”
   </a>
   .
  </p>
  <p>
   <a class="link" href="clone.html" title="15.7.5 CLONE Statement">
    <code class="literal">
     CLONE LOCAL DATA
      DIRECTORY
    </code>
   </a>
   syntax clones data from the local MySQL data
      directory to a directory on the same server or node where the
      MySQL server instance runs. The
   <code class="literal">
    'clone_dir'
   </code>
   directory is the full path of the local directory that data is
      cloned to. An absolute path is required. The specified directory
      must not exist, but the specified path must be an existent path.
      The MySQL server requires the necessary write access to create the
      specified directory. For more information, see
   <a class="xref" href="clone-plugin-local.html" title="7.6.7.2 Cloning Data Locally">
    Section 7.6.7.2, “Cloning Data Locally”
   </a>
   .
  </p>
  <p>
   <a class="link" href="clone.html" title="15.7.5 CLONE Statement">
    <code class="literal">
     CLONE INSTANCE
    </code>
   </a>
   syntax clones data from a remote MySQL server instance (the donor)
      and transfers it to the MySQL instance where the cloning operation
      was initiated (the recipient).
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       <em class="replaceable">
        <code>
         user
        </code>
       </em>
      </code>
      is the
          clone user on the donor MySQL server instance.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       <em class="replaceable">
        <code>
         host
        </code>
       </em>
      </code>
      is the
      <a class="link" href="server-system-variables.html#sysvar_hostname">
       <code class="literal">
        hostname
       </code>
      </a>
      address of the donor
          MySQL server instance. Internet Protocol version 6 (IPv6)
          address format is not supported. An alias to the IPv6 address
          can be used instead. An IPv4 address can be used as is.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       <em class="replaceable">
        <code>
         port
        </code>
       </em>
      </code>
      is the
      <a class="link" href="server-system-variables.html#sysvar_port">
       <code class="literal">
        port
       </code>
      </a>
      number of the donor
          MySQL server instance. (The X Protocol port specified by
      <a class="link" href="x-plugin-options-system-variables.html#sysvar_mysqlx_port">
       <code class="literal">
        mysqlx_port
       </code>
      </a>
      is not supported.
          Connecting to the donor MySQL server instance through MySQL Router
          is also not supported.)
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       IDENTIFIED BY
          '
       <em class="replaceable">
        <code>
         password
        </code>
       </em>
       '
      </code>
      specifies the
          password of the clone user on the donor MySQL server instance.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       DATA DIRECTORY [=]
          '
       <em class="replaceable">
        <code>
         clone_dir
        </code>
       </em>
       '
      </code>
      is an
          optional clause used to specify a directory on the recipient
          for the data you are cloning. Use this option if you do not
          want to remove existing data in the recipient data directory.
          An absolute path is required, and the directory must not
          exist. The MySQL server must have the necessary write access
          to create the directory.
     </p>
     <p>
      When the optional
      <code class="literal">
       DATA DIRECTORY [=]
          '
       <em class="replaceable">
        <code>
         clone_dir
        </code>
       </em>
       '
      </code>
      clause is not
          used, a cloning operation removes existing data in the
          recipient data directory, replaces it with the cloned data,
          and automatically restarts the server afterward.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       [REQUIRE [NO] SSL]
      </code>
      explicitly specifies
          whether an encrypted connection is to be used or not when
          transferring cloned data over the network. An error is
          returned if the explicit specification cannot be satisfied. If
          an SSL clause is not specified, clone attempts to establish an
          encrypted connection by default, falling back to an insecure
          connection if the secure connection attempt fails. A secure
          connection is required when cloning encrypted data regardless
          of whether this clause is specified. For more information, see
      <a class="xref" href="clone-plugin-remote.html#clone-plugin-remote-ssl" title="Configuring an Encrypted Connection for Cloning">
       Configuring an Encrypted Connection for Cloning
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   For additional information about cloning data from a remote MySQL
      server instance, see
   <a class="xref" href="clone-plugin-remote.html" title="7.6.7.3 Cloning Remote Data">
    Section 7.6.7.3, “Cloning Remote Data”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
