<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="connecting-using-uri-or-key-value-pairs">
      </a>
      6.2.5 Connecting to the Server Using URI-Like Strings or Key-Value Pairs
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045322678576">
  </a>
  <a class="indexterm" name="idm46045322677120">
  </a>
  <p>
   This section describes use of URI-like connection strings or
      key-value pairs to specify how to establish connections to the
      MySQL server, for clients such as MySQL Shell. For information on
      establishing connections using command-line options, for clients
      such as
   <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
    <span class="command">
     <strong>
      mysql
     </strong>
    </span>
   </a>
   or
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump
     </strong>
    </span>
   </a>
   ,
      see
   <a class="xref" href="connecting.html" title="6.2.4 Connecting to the MySQL Server Using Command Options">
    Section 6.2.4, “Connecting to the MySQL Server Using Command Options”
   </a>
   . For additional information if
      you are unable to connect, see
   <a class="xref" href="problems-connecting.html" title="8.2.22 Troubleshooting Problems Connecting to MySQL">
    Section 8.2.22, “Troubleshooting Problems Connecting to MySQL”
   </a>
   .
  </p>
  <a class="indexterm" name="idm46045322671072">
  </a>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    The term
    <span class="quote">
     “
     <span class="quote">
      URI-like
     </span>
     ”
    </span>
    signifies connection-string
        syntax that is similar to but not identical to the URI (uniform
        resource identifier) syntax defined by
    <a class="ulink" href="https://tools.ietf.org/html/rfc3986" target="_blank">
     RFC
        3986
    </a>
    .
   </p>
  </div>
  <p>
   The following MySQL clients support connecting to a MySQL server
      using a URI-like connection string or key-value pairs:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      MySQL Shell
     </p>
    </li>
    <li class="listitem">
     <p>
      MySQL Connectors which implement X DevAPI
     </p>
    </li>
   </ul>
  </div>
  <p>
   This section documents all valid URI-like string and key-value
      pair connection parameters, many of which are similar to those
      specified with command-line options:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Parameters specified with a URI-like string use a syntax such
          as
      <code class="literal">
       myuser@example.com:3306/main-schema
      </code>
      . For
          the full syntax, see
      <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-uri" title="Connecting Using URI-Like Connection Strings">
       Connecting Using URI-Like Connection Strings
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Parameters specified with key-value pairs use a syntax such as
      <code class="literal">
       {user:'myuser', host:'example.com', port:3306,
          schema:'main-schema'}
      </code>
      . For the full syntax, see
      <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-key-value-pairs" title="Connecting Using Key-Value Pairs">
       Connecting Using Key-Value Pairs
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   Connection parameters are not case-sensitive. Each parameter, if
      specified, can be given only once. If a parameter is specified
      more than once, an error occurs.
  </p>
  <p>
   This section covers the following topics:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-base" title="Base Connection Parameters">
       Base Connection Parameters
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-additional" title="Additional Connection parameters">
       Additional Connection parameters
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-uri" title="Connecting Using URI-Like Connection Strings">
       Connecting Using URI-Like Connection Strings
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-key-value-pairs" title="Connecting Using Key-Value Pairs">
       Connecting Using Key-Value Pairs
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="connection-parameters-base">
       </a>
       Base Connection Parameters
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045322652800">
   </a>
   <p>
    The following discussion describes the parameters available when
        specifying a connection to MySQL. These parameters can be
        provided using either a string that conforms to the base
        URI-like syntax (see
    <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-uri" title="Connecting Using URI-Like Connection Strings">
     Connecting Using URI-Like Connection Strings
    </a>
    ), or
        as key-value pairs (see
    <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connecting-using-key-value-pairs" title="Connecting Using Key-Value Pairs">
     Connecting Using Key-Value Pairs
    </a>
    ).
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         scheme
        </code>
       </em>
       : The transport protocol to
            use. Use
       <code class="literal">
        mysqlx
       </code>
       for X Protocol
            connections and
       <code class="literal">
        mysql
       </code>
       for
            classic MySQL protocol connections. If no protocol is specified,
            the server attempts to guess the protocol. Connectors that
            support DNS SRV can use the
       <code class="literal">
        mysqlx+srv
       </code>
       scheme (see
       <a class="ulink" href="/doc/x-devapi-userguide/en/connecting-dns-srv.html" target="_top">
        Connections Using DNS SRV Records
       </a>
       ).
      </p>
     </li>
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         user
        </code>
       </em>
       : The MySQL user account to
            provide for the authentication process.
      </p>
     </li>
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         password
        </code>
       </em>
       : The password to use for
            the authentication process.
      </p>
      <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Warning
       </div>
       <p>
        Specifying an explicit password in the connection
              specification is insecure and not recommended. Later
              discussion shows how to cause an interactive prompt for
              the password to occur.
       </p>
      </div>
     </li>
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         host
        </code>
       </em>
       : The host on which the
            server instance is running. The value can be a host name,
            IPv4 address, or IPv6 address. If no host is specified, the
            default is
       <code class="literal">
        localhost
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         port
        </code>
       </em>
       : The TCP/IP network port on
            which the target MySQL server is listening for connections.
            If no port is specified, the default is 33060 for
            X Protocol connections and 3306 for classic MySQL protocol
            connections.
      </p>
     </li>
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         socket
        </code>
       </em>
       : The path to a Unix socket
            file or the name of a Windows named pipe. Values are local
            file paths. In URI-like strings, they must be encoded, using
            either percent encoding or by surrounding the path with
            parentheses. Parentheses eliminate the need to percent
            encode characters such as the
       <code class="literal">
        /
       </code>
       directory
            separator character. For example, to connect as
       <code class="literal">
        root@localhost
       </code>
       using the Unix socket
       <code class="filename">
        /tmp/mysql.sock
       </code>
       , specify the path using
            percent encoding as
       <code class="literal">
        root@localhost?socket=%2Ftmp%2Fmysql.sock
       </code>
       ,
            or using parentheses as
       <code class="literal">
        root@localhost?socket=(/tmp/mysql.sock)
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <em class="replaceable">
        <code>
         schema
        </code>
       </em>
       : The default database for
            the connection. If no database is specified, the connection
            has no default database.
      </p>
     </li>
    </ul>
   </div>
   <p>
    The handling of
    <code class="literal">
     localhost
    </code>
    on Unix depends on
        the type of transport protocol. Connections using
        classic MySQL protocol handle
    <code class="literal">
     localhost
    </code>
    the same
        way as other MySQL clients, which means that
    <code class="literal">
     localhost
    </code>
    is assumed to be for socket-based
        connections. For connections using X Protocol, the behavior of
    <code class="literal">
     localhost
    </code>
    differs in that it is assumed to
        represent the loopback address, for example, IPv4 address
        127.0.0.1.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="connection-parameters-additional">
       </a>
       Additional Connection parameters
      </h4>
     </div>
    </div>
   </div>
   <p>
    You can specify options for the connection, either as attributes
        in a URI-like string by appending
    <code class="literal">
     ?
     <em class="replaceable">
      <code>
       attribute=value
      </code>
     </em>
    </code>
    ,
        or as key-value pairs. The following options are available:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-mode
       </code>
       : The desired security state for
            the connection. The following modes are permissible:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          <code class="literal">
           DISABLED
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           PREFERRED
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           REQUIRED
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           VERIFY_CA
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           VERIFY_IDENTITY
          </code>
         </p>
        </li>
       </ul>
      </div>
      <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Important
       </div>
       <p>
        <code class="literal">
         VERIFY_CA
        </code>
        and
        <code class="literal">
         VERIFY_IDENTITY
        </code>
        are better choices than
              the default
        <code class="literal">
         PREFERRED
        </code>
        , because they
              help prevent man-in-the-middle attacks.
       </p>
      </div>
      <p>
       For information about these modes, see the
       <a class="link" href="connection-options.html#option_general_ssl-mode">
        <code class="option">
         --ssl-mode
        </code>
       </a>
       option
            description in
       <a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
        Command Options for Encrypted Connections
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-ca
       </code>
       : The path to the X.509 certificate
            authority file in PEM format.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-capath
       </code>
       : The path to the directory
            that contains the X.509 certificates authority files in PEM
            format.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-cert
       </code>
       : The path to the X.509
            certificate file in PEM format.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-cipher
       </code>
       : The encryption cipher to use
            for connections that use TLS protocols up through TLSv1.2.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-crl
       </code>
       : The path to the file that
            contains certificate revocation lists in PEM format.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-crlpath
       </code>
       : The path to the directory
            that contains certificate revocation-list files in PEM
            format.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssl-key
       </code>
       : The path to the X.509 key file
            in PEM format.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        tls-version
       </code>
       : The TLS protocols permitted
            for classic MySQL protocol encrypted connections. This option is
            supported by MySQL Shell only. The value of
       <code class="literal">
        tls-version
       </code>
       (singular) is a comma
            separated list, for example
       <code class="literal">
        TLSv1.2,TLSv1.3
       </code>
       . For details, see
       <a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
        Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
       </a>
       .
            This option depends on the
       <code class="literal">
        ssl-mode
       </code>
       option not being set to
       <code class="literal">
        DISABLED
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        tls-versions
       </code>
       : The permissible TLS
            protocols for encrypted X Protocol connections. The value
            of
       <code class="literal">
        tls-versions
       </code>
       (plural) is an array such
            as
       <code class="literal">
        [TLSv1.2,TLSv1.3]
       </code>
       . For details, see
       <a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
        Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
       </a>
       .
            This option depends on the
       <code class="literal">
        ssl-mode
       </code>
       option not being set to
       <code class="literal">
        DISABLED
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        tls-ciphersuites
       </code>
       : The permitted TLS
            cipher suites. The value of
       <code class="literal">
        tls-ciphersuites
       </code>
       is a list of IANA cipher
            suite names as listed at
       <a class="ulink" href="https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4" target="_blank">
        TLS
            Ciphersuites
       </a>
       . For details, see
       <a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
        Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
       </a>
       .
            This option depends on the
       <code class="literal">
        ssl-mode
       </code>
       option not being set to
       <code class="literal">
        DISABLED
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        auth-method
       </code>
       : The authentication method to
            use for the connection. The default is
       <code class="literal">
        AUTO
       </code>
       , meaning that the server attempts to
            guess. The following methods are permissible:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          <code class="literal">
           AUTO
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           MYSQL41
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           SHA256_MEMORY
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           FROM_CAPABILITIES
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           FALLBACK
          </code>
         </p>
        </li>
        <li class="listitem">
         <p>
          <code class="literal">
           PLAIN
          </code>
         </p>
        </li>
       </ul>
      </div>
      <p>
       For X Protocol connections, any configured
       <code class="literal">
        auth-method
       </code>
       is overridden to this
            sequence of authentication methods:
       <code class="literal">
        MYSQL41
       </code>
       ,
       <code class="literal">
        SHA256_MEMORY
       </code>
       ,
       <code class="literal">
        PLAIN
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        get-server-public-key
       </code>
       : Request from the
            server the public key required for RSA key pair-based
            password exchange. Use when connecting to MySQL 8+ servers
            over classic MySQL protocol with SSL mode
       <code class="literal">
        DISABLED
       </code>
       . You must specify the protocol
            in this case. For example:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa88335432"><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">mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@localhost<span class="token operator">:</span>3306<span class="token operator">?</span>get<span class="token operator">-</span>server<span class="token operator">-</span>public<span class="token operator">-</span>key<span class="token operator">=</span>true</code></pre>
      </div>
      <p>
       This option applies to clients that authenticate with the
       <code class="literal">
        caching_sha2_password
       </code>
       authentication
            plugin. For that plugin, the server does not send the public
            key unless requested. This option is ignored for accounts
            that do not authenticate with that plugin. It is also
            ignored if RSA-based password exchange is not used, as is
            the case when the client connects to the server using a
            secure connection.
      </p>
      <p>
       If
       <code class="literal">
        server-public-key-path=
        <em class="replaceable">
         <code>
          file_name
         </code>
        </em>
       </code>
       is given and specifies a valid public key file, it takes
            precedence over
       <code class="literal">
        get-server-public-key
       </code>
       .
      </p>
      <p>
       For information about the
       <code class="literal">
        caching_sha2_password
       </code>
       plugin, see
       <a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
        Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        server-public-key-path
       </code>
       : The path name to
            a file in PEM format containing a client-side copy of the
            public key required by the server for RSA key pair-based
            password exchange. Use when connecting to MySQL 8+ servers
            over classic MySQL protocol with SSL mode
       <code class="literal">
        DISABLED
       </code>
       .
      </p>
      <p>
       This option applies to clients that authenticate with the
       <code class="literal">
        sha256_password
       </code>
       (deprecated) or
       <code class="literal">
        caching_sha2_password
       </code>
       authentication
            plugin. This option is ignored for accounts that do not
            authenticate with one of those plugins. It is also ignored
            if RSA-based password exchange is not used, as is the case
            when the client connects to the server using a secure
            connection.
      </p>
      <p>
       If
       <code class="literal">
        server-public-key-path=
        <em class="replaceable">
         <code>
          file_name
         </code>
        </em>
       </code>
       is given and specifies a valid public key file, it takes
            precedence over
       <code class="literal">
        get-server-public-key
       </code>
       .
      </p>
      <p>
       For information about the
       <code class="literal">
        sha256_password
       </code>
       (deprecated) and
       <code class="literal">
        caching_sha2_password
       </code>
       plugins, see
       <a class="xref" href="sha256-pluggable-authentication.html" title="8.4.1.3 SHA-256 Pluggable Authentication">
        Section 8.4.1.3, “SHA-256 Pluggable Authentication”
       </a>
       , and
       <a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
        Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssh
       </code>
       : The URI for connection to an SSH
            server to access a MySQL server instance using SSH
            tunneling. The URI format is
       <code class="literal">
        [user@]host[:port]
       </code>
       . Use the
       <code class="literal">
        uri
       </code>
       option to specify the URI of the
            target MySQL server instance. For information on SSH tunnel
            connections from MySQL Shell, see
       <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-connection-ssh.html" target="_top">
        Using an SSH Tunnel
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        uri
       </code>
       : The URI for a MySQL server instance
            that is to be accessed through an SSH tunnel from the server
            specified by the
       <code class="literal">
        ssh
       </code>
       option. The URI
            format is
       <code class="literal">
        [scheme://][user@]host[:port]
       </code>
       .
            Do not use the base connection parameters
            (
       <code class="literal">
        scheme
       </code>
       ,
       <code class="literal">
        user
       </code>
       ,
       <code class="literal">
        host
       </code>
       ,
       <code class="literal">
        port
       </code>
       ) to specify
            the MySQL server connection for SSH tunneling, just use the
       <code class="literal">
        uri
       </code>
       option.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssh-password
       </code>
       : The password for the
            connection to the SSH server.
      </p>
      <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Warning
       </div>
       <p>
        Specifying an explicit password in the connection
              specification is insecure and not recommended.
              MySQL Shell prompts for a password interactively when one
              is required.
       </p>
      </div>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssh-config-file
       </code>
       : The SSH configuration
            file for the connection to the SSH server. You can use the
            MySQL Shell configuration option
       <code class="literal">
        ssh.configFile
       </code>
       to set a custom file as
            the default if this option is not specified. If
       <code class="literal">
        ssh.configFile
       </code>
       has not been set, the
            default is the standard SSH configuration file
       <code class="literal">
        ~/.ssh/config
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssh-identity-file
       </code>
       : The identity file to
            use for the connection to the SSH server. The default if
            this option is not specified is any identity file configured
            in an SSH agent (if used), or in the SSH configuration file,
            or the standard private key file in the SSH configuration
            folder (
       <code class="literal">
        ~/.ssh/id_rsa
       </code>
       ).
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        ssh-identity-pass
       </code>
       : The passphrase for the
            identity file specified by the
       <code class="literal">
        ssh-identity-file
       </code>
       option.
      </p>
      <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Warning
       </div>
       <p>
        Specifying an explicit password in the connection
              specification is insecure and not recommended.
              MySQL Shell prompts for a password interactively when one
              is required.
       </p>
      </div>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        connect-timeout
       </code>
       : An integer value used to
            configure the number of seconds that clients, such as
            MySQL Shell, wait until they stop trying to connect to an
            unresponsive MySQL server.
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        compression
       </code>
       : This option requests or
            disables compression for the connection.
      </p>
      <p>
       The values available for this option are:
       <code class="literal">
        required
       </code>
       , which requests compression and
            fails if the server does not support it;
       <code class="literal">
        preferred
       </code>
       , which requests compression and
            falls back to an uncompressed connection; and
       <code class="literal">
        disabled
       </code>
       , which requests an uncompressed
            connection and fails if the server does not permit those.
       <code class="literal">
        preferred
       </code>
       is the default for X Protocol
            connections, and
       <code class="literal">
        disabled
       </code>
       is the default
            for classic MySQL protocol connections. For information on
            X Plugin connection compression control, see
       <a class="xref" href="x-plugin-connection-compression.html" title="22.5.5 Connection Compression with X Plugin">
        Section 22.5.5, “Connection Compression with X Plugin”
       </a>
       .
      </p>
      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
       <div class="admon-title">
        Note
       </div>
       <p>
        Different MySQL clients implement their support for
              connection compression differently. Consult your client's
              documentation for details.
       </p>
      </div>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        compression-algorithms
       </code>
       and
       <code class="literal">
        compression-level
       </code>
       : These options are
            available in MySQL Shell for more control over connection
            compression. You can specify them to select the compression
            algorithm used for the connection, and the numeric
            compression level used with that algorithm. You can also use
       <code class="literal">
        compression-algorithms
       </code>
       in place of
       <code class="literal">
        compression
       </code>
       to request compression for
            the connection. For information on MySQL Shell's connection
            compression control, see
       <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-compressed-connections.html" target="_top">
        Using Compressed Connections
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        connection-attributes
       </code>
       : Controls the
            key-value pairs that application programs pass to the server
            at connect time. For general information about connection
            attributes, see
       <a class="xref" href="performance-schema-connection-attribute-tables.html" title="29.12.9 Performance Schema Connection Attribute Tables">
        Section 29.12.9, “Performance Schema Connection Attribute Tables”
       </a>
       .
            Clients usually define a default set of attributes, which
            can be disabled or enabled. For example:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa81331129"><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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span>true
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span>false</code></pre>
      </div>
      <p>
       The default behavior is to send the default attribute set.
            Applications can specify attributes to be passed in addition
            to the default attributes. You specify additional connection
            attributes as a
       <code class="literal">
        connection-attributes
       </code>
       parameter in a connection string. The
       <code class="literal">
        connection-attributes
       </code>
       parameter value
            must be empty (the same as specifying
       <code class="literal">
        true
       </code>
       ), a
       <code class="literal">
        Boolean
       </code>
       value
            (
       <code class="literal">
        true
       </code>
       or
       <code class="literal">
        false
       </code>
       to
            enable or disable the default attribute set), or a list or
            zero or more
       <code class="literal">
        key=value
       </code>
       specifiers
            separated by commas (to be sent in addition to the default
            attribute set). Within a list, a missing key value evaluates
            as an empty string. Further examples:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa18975580"><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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span><span class="token punctuation">[</span>attr1<span class="token operator">=</span>val1<span class="token punctuation">,</span>attr2<span class="token punctuation">,</span>attr3<span class="token operator">=</span><span class="token punctuation">]</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span>user@host<span class="token operator">?</span>connection<span class="token operator">-</span>attributes<span class="token operator">=</span><span class="token punctuation">[</span><span class="token punctuation">]</span></code></pre>
      </div>
      <p>
       Application-defined attribute names cannot begin with
       <code class="literal">
        _
       </code>
       because such names are reserved for
            internal attributes.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="connecting-using-uri">
       </a>
       Connecting Using URI-Like Connection Strings
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045322495968">
   </a>
   <p>
    You can specify a connection to MySQL Server using a URI-like
        string. Such strings can be used with the MySQL Shell with the
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysqlsh.html#option_mysqlsh_uri" target="_top">
     <code class="option">
      --uri
     </code>
    </a>
    command option, the
        MySQL Shell
    <code class="literal">
     \connect
    </code>
    command, and MySQL
        Connectors which implement X DevAPI.
   </p>
   <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Note
    </div>
    <p>
     The term
     <span class="quote">
      “
      <span class="quote">
       URI-like
      </span>
      ”
     </span>
     signifies connection-string
          syntax that is similar to but not identical to the URI
          (uniform resource identifier) syntax defined by
     <a class="ulink" href="https://tools.ietf.org/html/rfc3986" target="_blank">
      RFC
          3986
     </a>
     .
    </p>
   </div>
   <p>
    A URI-like connection string has the following syntax:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa43213184"><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"><span class="token punctuation">[</span><em class="replaceable">scheme</em><span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><span class="token punctuation">]</span><span class="token punctuation">[</span><em class="replaceable">user</em><span class="token punctuation">[</span><span class="token operator">:</span><span class="token punctuation">[</span><em class="replaceable">password</em><span class="token punctuation">]</span><span class="token punctuation">]</span>@<span class="token punctuation">]</span><em class="replaceable">host</em><span class="token punctuation">[</span><span class="token operator">:</span><em class="replaceable">port</em><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token operator">/</span><em class="replaceable">schema</em><span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token operator">?</span><em class="replaceable">attribute1<span class="token operator">=</span>value1<span class="token operator">&amp;</span>attribute2<span class="token operator">=</span>value2<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></em><span class="token punctuation"></span></code></pre>
   </div>
   <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Important
    </div>
    <p>
     Percent encoding must be used for reserved characters in the
          elements of the URI-like string. For example, if you specify a
          string that includes the
     <code class="literal">
      @
     </code>
     character, the
          character must be replaced by
     <code class="literal">
      %40
     </code>
     . If you
          include a zone ID in an IPv6 address, the
     <code class="literal">
      %
     </code>
     character used as the separator must be replaced with
     <code class="literal">
      %25
     </code>
     .
    </p>
   </div>
   <p>
    The parameters you can use in a URI-like connection string are
        described at
    <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-base" title="Base Connection Parameters">
     Base Connection Parameters
    </a>
    .
   </p>
   <p>
    MySQL Shell's
    <code class="literal">
     shell.parseUri()
    </code>
    and
    <code class="literal">
     shell.unparseUri()
    </code>
    methods can be used to
        deconstruct and assemble a URI-like connection string. Given a
        URI-like connection string,
    <code class="literal">
     shell.parseUri()
    </code>
    returns a dictionary containing each element found in the
        string.
    <code class="literal">
     shell.unparseUri()
    </code>
    converts a
        dictionary of URI components and connection options into a valid
        URI-like connection string for connecting to MySQL, which can be
        used in MySQL Shell or by MySQL Connectors which implement
        X DevAPI.
   </p>
   <p>
    If no password is specified in the URI-like string, which is
        recommended, interactive clients prompt for the password. The
        following examples show how to specify URI-like strings with the
        user name
    <em class="replaceable">
     <code>
      user_name
     </code>
    </em>
    . In each case,
        the password is prompted for.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       An X Protocol connection to a local server instance
            listening at port 33065.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2420919"><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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@localhost<span class="token operator">:</span>33065</code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A classic MySQL protocol connection to a local server instance
            listening at port 3333.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa28795018"><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">mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@localhost<span class="token operator">:</span>3333</code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An X Protocol connection to a remote server instance, using
            a host name, an IPv4 address, and an IPv6 address.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa63382840"><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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@server<span class="token punctuation">.</span>example<span class="token punctuation">.</span>com<span class="token operator">/</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>14<span class="token operator">:</span>123
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@<span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An X Protocol connection using a socket, with the path
            provided using either percent encoding or parentheses.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa16057668"><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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@<span class="token operator">/</span><em class="replaceable">path</em><span class="token operator">%</span>2F<em class="replaceable">to</em><span class="token operator">%</span>2F<em class="replaceable">socket<span class="token punctuation">.</span>sock</em>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@<span class="token punctuation">(</span><span class="token operator"></span><em class="replaceable"><span class="token operator">/</span>path<span class="token operator">/</span>to<span class="token operator">/</span>socket<span class="token punctuation">.</span>sock</em><span class="token punctuation">)</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An optional path can be specified, which represents a
            database.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa14034423"><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"><span class="token comment" spellcheck="true"># use 'world' as the default database</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>1<span class="token operator">/</span>world

<span class="token comment" spellcheck="true"># use 'world_x' as the default database, encoding _ as %5F</span>
mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2<span class="token operator">:</span>33060<span class="token operator">/</span>world<span class="token operator">%</span>5Fx</code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An optional query can be specified, consisting of values
            each given as a
       <code class="literal">
        <em class="replaceable">
         <code>
          key
         </code>
        </em>
        =
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
       </code>
       pair or as a single
       <em class="replaceable">
        <code>
         key
        </code>
       </em>
       . To
            specify multiple values, separate them by
       <code class="literal">
        ,
       </code>
       characters. A mix of
       <code class="literal">
        <em class="replaceable">
         <code>
          key
         </code>
        </em>
        =
        <em class="replaceable">
         <code>
          value
         </code>
        </em>
       </code>
       and
       <em class="replaceable">
        <code>
         key
        </code>
       </em>
       values is permissible.
            Values can be of type list, with list values ordered by
            appearance. Strings must be either percent encoded or
            surrounded by parentheses. The following are equivalent.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa9097626"><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">ssluser@127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1<span class="token operator">?</span>ssl<span class="token operator">-</span>ca<span class="token operator">=</span><span class="token operator">%</span>2Froot<span class="token operator">%</span>2Fclientcert<span class="token operator">%</span>2Fca<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem\
<span class="token operator">&amp;</span>ssl<span class="token operator">-</span>cert<span class="token operator">=</span><span class="token operator">%</span>2Froot<span class="token operator">%</span>2Fclientcert<span class="token operator">%</span>2Fclient<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem\
<span class="token operator">&amp;</span>ssl<span class="token operator">-</span>key<span class="token operator">=</span><span class="token operator">%</span>2Froot<span class="token operator">%</span>2Fclientcert<span class="token operator">%</span>2Fclient<span class="token operator">-</span>key

ssluser@127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1<span class="token operator">?</span>ssl<span class="token operator">-</span>ca<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">/</span>root<span class="token operator">/</span>clientcert<span class="token operator">/</span>ca<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem<span class="token punctuation">)</span>\
<span class="token operator">&amp;</span>ssl<span class="token operator">-</span>cert<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">/</span>root<span class="token operator">/</span>clientcert<span class="token operator">/</span>client<span class="token operator">-</span>cert<span class="token punctuation">.</span>pem<span class="token punctuation">)</span>\
<span class="token operator">&amp;</span>ssl<span class="token operator">-</span>key<span class="token operator">=</span><span class="token punctuation">(</span><span class="token operator">/</span>root<span class="token operator">/</span>clientcert<span class="token operator">/</span>client<span class="token operator">-</span>key<span class="token punctuation">)</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       To specify a TLS version and ciphersuite to use for
            encrypted connections:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa18824530"><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">mysql<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em>@198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>2<span class="token operator">:</span>3306<span class="token operator">/</span>world<span class="token operator">%</span>5Fx<span class="token operator">?</span>\
tls<span class="token operator">-</span>versions<span class="token operator">=</span><span class="token punctuation">[</span>TLSv1<span class="token punctuation">.</span>2<span class="token punctuation">,</span>TLSv1<span class="token punctuation">.</span>3<span class="token punctuation">]</span><span class="token operator">&amp;</span>tls<span class="token operator">-</span>ciphersuites<span class="token operator">=</span><span class="token punctuation">[</span>TLS_DHE_PSK_WITH_AES_128_\
GCM_SHA256<span class="token punctuation">,</span> TLS_CHACHA20_POLY1305_SHA256<span class="token punctuation">]</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    The previous examples assume that connections require a
        password. With interactive clients, the specified user's
        password is requested at the login prompt. If the user account
        has no password (which is insecure and not recommended), or if
        socket peer-credential authentication is in use (for example,
        with Unix socket connections), you must explicitly specify in
        the connection string that no password is being provided and the
        password prompt is not required. To do this, place a
    <code class="literal">
     :
    </code>
    after the
    <em class="replaceable">
     <code>
      user_name
     </code>
    </em>
    in the string but do not
        specify a password after it. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa33817309"><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">mysqlx<span class="token operator">:</span><span class="token operator">/</span><span class="token operator">/</span><em class="replaceable">user_name</em><span class="token operator">:</span>@localhost</code></pre>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="connecting-using-key-value-pairs">
       </a>
       Connecting Using Key-Value Pairs
      </h4>
     </div>
    </div>
   </div>
   <a class="indexterm" name="idm46045322444848">
   </a>
   <p>
    In MySQL Shell and some MySQL Connectors which implement
        X DevAPI, you can specify a connection to MySQL Server using
        key-value pairs, supplied in language-natural constructs for the
        implementation. For example, you can supply connection
        parameters using key-value pairs as a JSON object in JavaScript,
        or as a dictionary in Python. Regardless of the way the
        key-value pairs are supplied, the concept remains the same: the
        keys as described in this section can be assigned values that
        are used to specify a connection. You can specify connections
        using key-value pairs in MySQL Shell's
    <code class="literal">
     shell.connect()
    </code>
    method or InnoDB Cluster's
    <code class="literal">
     dba.createCluster()
    </code>
    method, and with some of
        the MySQL Connectors which implement X DevAPI.
   </p>
   <p>
    Generally, key-value pairs are surrounded by
    <code class="literal">
     {
    </code>
    and
    <code class="literal">
     }
    </code>
    characters and the
    <code class="literal">
     ,
    </code>
    character is used as a separator between
        key-value pairs. The
    <code class="literal">
     :
    </code>
    character is used
        between keys and values, and strings must be delimited (for
        example, using the
    <code class="literal">
     '
    </code>
    character). It is not
        necessary to percent encode strings, unlike URI-like connection
        strings.
   </p>
   <p>
    A connection specified as key-value pairs has the following
        format:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa47076036"><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"><span class="token punctuation">{</span> <em class="replaceable">key</em><span class="token operator">:</span> <em class="replaceable">value</em><span class="token punctuation">,</span> <em class="replaceable">key</em><span class="token operator">:</span> <em class="replaceable">value</em><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></code></pre>
   </div>
   <p>
    The parameters you can use as keys for a connection are
        described at
    <a class="xref" href="connecting-using-uri-or-key-value-pairs.html#connection-parameters-base" title="Base Connection Parameters">
     Base Connection Parameters
    </a>
    .
   </p>
   <p>
    If no password is specified in the key-value pairs, which is
        recommended, interactive clients prompt for the password. The
        following examples show how to specify connections using
        key-value pairs with the user name
    <code class="literal">
     '
     <em class="replaceable">
      <code>
       user_name
      </code>
     </em>
     '
    </code>
    . In
        each case, the password is prompted for.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       An X Protocol connection to a local server instance
            listening at port 33065.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa57425353"><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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">,</span> port<span class="token operator">:</span>33065<span class="token punctuation">}</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       A classic MySQL protocol connection to a local server instance
            listening at port 3333.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa8621848"><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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">,</span> port<span class="token operator">:</span>3333<span class="token punctuation">}</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An X Protocol connection to a remote server instance, using
            a host name, an IPv4 address, and an IPv6 address.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-simple"><div class="docs-select-all right" id="sa49865985"><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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'server<span class="token punctuation">.</span>example<span class="token punctuation">.</span>com'<span class="token punctuation">}</span>
<span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>198<span class="token punctuation">.</span>51<span class="token punctuation">.</span>100<span class="token punctuation">.</span>14<span class="token operator">:</span>123<span class="token punctuation">}</span>
<span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span><span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span><span class="token punctuation">}</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An X Protocol connection using a socket.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa43812348"><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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> socket<span class="token operator">:</span>'<span class="token operator"></span><em class="replaceable"><span class="token operator">/</span>path<span class="token operator">/</span>to<span class="token operator">/</span>socket<span class="token operator">/</span>file</em>'<span class="token punctuation">}</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       An optional schema can be specified, which represents a
            database.
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa2510072"><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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">,</span> schema<span class="token operator">:</span>'world'<span class="token punctuation">}</span></code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    The previous examples assume that connections require a
        password. With interactive clients, the specified user's
        password is requested at the login prompt. If the user account
        has no password (which is insecure and not recommended), or if
        socket peer-credential authentication is in use (for example,
        with Unix socket connections), you must explicitly specify that
        no password is being provided and the password prompt is not
        required. To do this, provide an empty string using
    <code class="literal">
     ''
    </code>
    after the
    <code class="literal">
     password
    </code>
    key.
        For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa99734671"><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"><span class="token punctuation">{</span>user<span class="token operator">:</span>'<em class="replaceable">user_name</em>'<span class="token punctuation">,</span> password<span class="token operator">:</span>''<span class="token punctuation">,</span> host<span class="token operator">:</span>'localhost'<span class="token punctuation">}</span></code></pre>
   </div>
  </div>
 </div>
 <br/>
</div>
