<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="ipv6-remote-connections">
      </a>
      7.1.13.4 Connecting Using IPv6 Nonlocal Host Addresses
     </h4>
    </div>
   </div>
  </div>
  <p>
   The following procedure shows how to configure MySQL to permit
        IPv6 connections by remote clients. It is similar to the
        preceding procedure for local clients, but the server and client
        hosts are distinct and each has its own nonlocal IPv6 address.
        The example uses these addresses:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa38464542"><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-simple">Server host<span class="token operator">:</span> 2001<span class="token operator">:</span>db8<span class="token operator">:</span>0<span class="token operator">:</span>f101<span class="token operator">:</span><span class="token operator">:</span>1
Client host<span class="token operator">:</span> 2001<span class="token operator">:</span>db8<span class="token operator">:</span>0<span class="token operator">:</span>f101<span class="token operator">:</span><span class="token operator">:</span>2</code></pre>
  </div>
  <p>
   These addresses are chosen from the nonroutable address range
        recommended by
   <a class="ulink" href="http://www.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.xml" target="_blank">
    IANA
   </a>
   for documentation purposes and suffice for testing on your local
        network. To accept IPv6 connections from clients outside the
        local network, the server host must have a public address. If
        your network provider assigns you an IPv6 address, you can use
        that. Otherwise, another way to obtain an address is to use an
        IPv6 broker; see
   <a class="xref" href="ipv6-brokers.html" title="7.1.13.5 Obtaining an IPv6 Address from a Broker">
    Section 7.1.13.5, “Obtaining an IPv6 Address from a Broker”
   </a>
   .
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Start the MySQL server with an appropriate
      <a class="link" href="server-system-variables.html#sysvar_bind_address">
       <code class="literal">
        bind_address
       </code>
      </a>
      setting to
            permit it to accept IPv6 connections. For example, put the
            following lines in the server option file and restart the
            server:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa10941869"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">bind_address</span> <span class="token attr-value"><span class="token punctuation">=</span> *</span></code></pre>
     </div>
     <p>
      Specifying * (or
      <code class="literal">
       ::
      </code>
      ) as the value for
      <a class="link" href="server-system-variables.html#sysvar_bind_address">
       <code class="literal">
        bind_address
       </code>
      </a>
      permits both
            IPv4 and IPv6 connections on all server host IPv4 and IPv6
            interfaces. If you want to bind the server to a specific
            list of addresses, you can do this by specifying a
            comma-separated list of values for
      <a class="link" href="server-system-variables.html#sysvar_bind_address">
       <code class="literal">
        bind_address
       </code>
      </a>
      . This example
            specifies an IPv4 address as well as the required server
            host IPv6 address:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-ini"><div class="docs-select-all right" id="sa69210539"><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-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">bind_address</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.20,2001:db8:0:f101::1</span></code></pre>
     </div>
     <p>
      For more information, see the
      <a class="link" href="server-system-variables.html#sysvar_bind_address">
       <code class="literal">
        bind_address
       </code>
      </a>
      description in
      <a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
       Section 7.1.8, “Server System Variables”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      On the server host (
      <code class="literal">
       2001:db8:0:f101::1
      </code>
      ),
            create an account for a user who can connect from the client
            host (
      <code class="literal">
       2001:db8:0:f101::2
      </code>
      ):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa11188695"><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">USER</span> <span class="token string">'remoteipv6user'</span>@<span class="token string">'2001:db8:0:f101::2'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'remoteipv6pass'</span><span class="token punctuation">;</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      On the client host (
      <code class="literal">
       2001:db8:0:f101::2
      </code>
      ),
            invoke 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 to connect to the
            server using the new account:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa33139312"><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> <span class="token property">-h</span> 2001<span class="token punctuation">:</span>db8<span class="token punctuation">:</span>0<span class="token punctuation">:</span>f101<span class="token punctuation">:</span><span class="token punctuation">:</span>1 <span class="token property">-u</span> remoteipv6user <span class="token property">-premoteipv6pass</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Try some simple statements that show connection information:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa85907443"><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">STATUS</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">Connection</span>:   <span class="token number">2001</span>:db8:<span class="token number">0</span>:f101::<span class="token number">1</span> via TCP<span class="token operator">/</span>IP
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CURRENT_USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@@bind_address</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> CURRENT_USER()                    <span class="token punctuation">|</span> @@bind_address <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> remoteipv6user@2001:db8:0:f101::2 <span class="token punctuation">|</span> ::             <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
    </li>
   </ol>
  </div>
 </div>
 <br/>
</div>
