<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="performance-schema-host-cache-table">
      </a>
      29.12.22.3 The host_cache Table
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045067598896">
  </a>
  <a class="indexterm" name="idm46045067597408">
  </a>
  <p>
   The MySQL server maintains an in-memory host cache that
          contains client host name and IP address information and is
          used to avoid Domain Name System (DNS) lookups. The
   <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
    <code class="literal">
     host_cache
    </code>
   </a>
   table exposes the
          contents of this cache. The
   <a class="link" href="server-system-variables.html#sysvar_host_cache_size">
    <code class="literal">
     host_cache_size
    </code>
   </a>
   system
          variable controls the size of the host cache, as well as the
          size of the
   <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
    <code class="literal">
     host_cache
    </code>
   </a>
   table. For
          operational and configuration information about the host
          cache, see
   <a class="xref" href="host-cache.html" title="7.1.12.3 DNS Lookups and the Host Cache">
    Section 7.1.12.3, “DNS Lookups and the Host Cache”
   </a>
   .
  </p>
  <p>
   Because the
   <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
    <code class="literal">
     host_cache
    </code>
   </a>
   table
          exposes the contents of the host cache, it can be examined
          using
   <a class="link" href="select.html" title="15.2.13 SELECT Statement">
    <code class="literal">
     SELECT
    </code>
   </a>
   statements. This
          may help you diagnose the causes of connection problems.
  </p>
  <p>
   The
   <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
    <code class="literal">
     host_cache
    </code>
   </a>
   table has these
          columns:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       IP
      </code>
     </p>
     <p>
      The IP address of the client that connected to the server,
              expressed as a string.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       HOST
      </code>
     </p>
     <p>
      The resolved DNS host name for that client IP, or
      <code class="literal">
       NULL
      </code>
      if the name is unknown.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       HOST_VALIDATED
      </code>
     </p>
     <p>
      Whether the IP-to-host name-to-IP DNS resolution was
              performed successfully for the client IP. If
      <code class="literal">
       HOST_VALIDATED
      </code>
      is
      <code class="literal">
       YES
      </code>
      , the
      <code class="literal">
       HOST
      </code>
      column
              is used as the host name corresponding to the IP so that
              additional calls to DNS can be avoided. While
      <code class="literal">
       HOST_VALIDATED
      </code>
      is
      <code class="literal">
       NO
      </code>
      , DNS resolution is attempted for
              each connection attempt, until it eventually completes
              with either a valid result or a permanent error. This
              information enables the server to avoid caching bad or
              missing host names during temporary DNS failures, which
              would negatively affect clients forever.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
     </p>
     <p>
      The number of connection errors that are deemed
      <span class="quote">
       “
       <span class="quote">
        blocking
       </span>
       ”
      </span>
      (assessed against the
      <a class="link" href="server-system-variables.html#sysvar_max_connect_errors">
       <code class="literal">
        max_connect_errors
       </code>
      </a>
      system
              variable). Only protocol handshake errors are counted, and
              only for hosts that passed validation
              (
      <code class="literal">
       HOST_VALIDATED = YES
      </code>
      ).
     </p>
     <p>
      Once
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      for a given
              host reaches the value of
      <a class="link" href="server-system-variables.html#sysvar_max_connect_errors">
       <code class="literal">
        max_connect_errors
       </code>
      </a>
      , new
              connections from that host are blocked. The
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      value can exceed the
      <a class="link" href="server-system-variables.html#sysvar_max_connect_errors">
       <code class="literal">
        max_connect_errors
       </code>
      </a>
      value
              because multiple connection attempts from a host can occur
              simultaneously while the host is not blocked. Any or all
              of them can fail, independently incrementing
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      , possibly beyond the
              value of
      <a class="link" href="server-system-variables.html#sysvar_max_connect_errors">
       <code class="literal">
        max_connect_errors
       </code>
      </a>
      .
     </p>
     <p>
      Suppose that
      <a class="link" href="server-system-variables.html#sysvar_max_connect_errors">
       <code class="literal">
        max_connect_errors
       </code>
      </a>
      is 200
              and
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      for a given host
              is 199. If 10 clients attempt to connect from that host
              simultaneously, none of them are blocked because
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      has not reached 200.
              If blocking errors occur for five of the clients,
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      is increased by one
              for each client, for a resulting
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      value of 204. The
              other five clients succeed and are not blocked because the
              value of
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      when their
              connection attempts began had not reached 200. New
              connections from the host that begin after
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      reaches 200 are
              blocked.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_HOST_BLOCKED_ERRORS
      </code>
     </p>
     <p>
      The number of connections that were blocked because
      <code class="literal">
       SUM_CONNECT_ERRORS
      </code>
      exceeded the value
              of the
      <a class="link" href="server-system-variables.html#sysvar_max_connect_errors">
       <code class="literal">
        max_connect_errors
       </code>
      </a>
      system variable.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_NAMEINFO_TRANSIENT_ERRORS
      </code>
     </p>
     <p>
      The number of transient errors during IP-to-host name DNS
              resolution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_NAMEINFO_PERMANENT_ERRORS
      </code>
     </p>
     <p>
      The number of permanent errors during IP-to-host name DNS
              resolution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_FORMAT_ERRORS
      </code>
     </p>
     <p>
      The number of host name format errors. MySQL does not
              perform matching of
      <code class="literal">
       Host
      </code>
      column values
              in the
      <code class="literal">
       mysql.user
      </code>
      system table against
              host names for which one or more of the initial components
              of the name are entirely numeric, such as
      <code class="literal">
       1.2.example.com
      </code>
      . The client IP address
              is used instead. For the rationale why this type of
              matching does not occur, see
      <a class="xref" href="account-names.html" title="8.2.4 Specifying Account Names">
       Section 8.2.4, “Specifying Account Names”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_ADDRINFO_TRANSIENT_ERRORS
      </code>
     </p>
     <p>
      The number of transient errors during host name-to-IP
              reverse DNS resolution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_ADDRINFO_PERMANENT_ERRORS
      </code>
     </p>
     <p>
      The number of permanent errors during host name-to-IP
              reverse DNS resolution.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_FCRDNS_ERRORS
      </code>
     </p>
     <p>
      The number of forward-confirmed reverse DNS errors. These
              errors occur when IP-to-host name-to-IP DNS resolution
              produces an IP address that does not match the client
              originating IP address.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_HOST_ACL_ERRORS
      </code>
     </p>
     <p>
      The number of errors that occur because no users are
              permitted to connect from the client host. In such cases,
              the server returns
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_host_not_privileged" target="_top">
       <code class="literal">
        ER_HOST_NOT_PRIVILEGED
       </code>
      </a>
      and
              does not even ask for a user name or password.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_NO_AUTH_PLUGIN_ERRORS
      </code>
     </p>
     <p>
      The number of errors due to requests for an unavailable
              authentication plugin. A plugin can be unavailable if, for
              example, it was never loaded or a load attempt failed.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_AUTH_PLUGIN_ERRORS
      </code>
     </p>
     <p>
      The number of errors reported by authentication plugins.
     </p>
     <p>
      An authentication plugin can report different error codes
              to indicate the root cause of a failure. Depending on the
              type of error, one of these columns is incremented:
      <code class="literal">
       COUNT_AUTHENTICATION_ERRORS
      </code>
      ,
      <code class="literal">
       COUNT_AUTH_PLUGIN_ERRORS
      </code>
      ,
      <code class="literal">
       COUNT_HANDSHAKE_ERRORS
      </code>
      . New return
              codes are an optional extension to the existing plugin
              API. Unknown or unexpected plugin errors are counted in
              the
      <code class="literal">
       COUNT_AUTH_PLUGIN_ERRORS
      </code>
      column.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_HANDSHAKE_ERRORS
      </code>
     </p>
     <p>
      The number of errors detected at the wire protocol level.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_PROXY_USER_ERRORS
      </code>
     </p>
     <p>
      The number of errors detected when proxy user A is proxied
              to another user B who does not exist.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_PROXY_USER_ACL_ERRORS
      </code>
     </p>
     <p>
      The number of errors detected when proxy user A is proxied
              to another user B who does exist but for whom A does not
              have the
      <a class="link" href="privileges-provided.html#priv_proxy">
       <code class="literal">
        PROXY
       </code>
      </a>
      privilege.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_AUTHENTICATION_ERRORS
      </code>
     </p>
     <p>
      The number of errors caused by failed authentication.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_SSL_ERRORS
      </code>
     </p>
     <p>
      The number of errors due to SSL problems.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_MAX_USER_CONNECTIONS_ERRORS
      </code>
     </p>
     <p>
      The number of errors caused by exceeding per-user
              connection quotas. See
      <a class="xref" href="user-resources.html" title="8.2.21 Setting Account Resource Limits">
       Section 8.2.21, “Setting Account Resource Limits”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_MAX_USER_CONNECTIONS_PER_HOUR_ERRORS
      </code>
     </p>
     <p>
      The number of errors caused by exceeding per-user
              connections-per-hour quotas. See
      <a class="xref" href="user-resources.html" title="8.2.21 Setting Account Resource Limits">
       Section 8.2.21, “Setting Account Resource Limits”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_DEFAULT_DATABASE_ERRORS
      </code>
     </p>
     <p>
      The number of errors related to the default database. For
              example, the database does not exist or the user has no
              privileges to access it.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_INIT_CONNECT_ERRORS
      </code>
     </p>
     <p>
      The number of errors caused by execution failures of
              statements in the
      <a class="link" href="server-system-variables.html#sysvar_init_connect">
       <code class="literal">
        init_connect
       </code>
      </a>
      system
              variable value.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_LOCAL_ERRORS
      </code>
     </p>
     <p>
      The number of errors local to the server implementation
              and not related to the network, authentication, or
              authorization. For example, out-of-memory conditions fall
              into this category.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       COUNT_UNKNOWN_ERRORS
      </code>
     </p>
     <p>
      The number of other, unknown errors not accounted for by
              other columns in this table. This column is reserved for
              future use, in case new error conditions must be reported,
              and if preserving the backward compatibility and structure
              of the
      <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
       <code class="literal">
        host_cache
       </code>
      </a>
      table is
              required.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       FIRST_SEEN
      </code>
     </p>
     <p>
      The timestamp of the first connection attempt seen from
              the client in the
      <code class="literal">
       IP
      </code>
      column.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LAST_SEEN
      </code>
     </p>
     <p>
      The timestamp of the most recent connection attempt seen
              from the client in the
      <code class="literal">
       IP
      </code>
      column.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       FIRST_ERROR_SEEN
      </code>
     </p>
     <p>
      The timestamp of the first error seen from the client in
              the
      <code class="literal">
       IP
      </code>
      column.
     </p>
    </li>
    <li class="listitem">
     <p>
      <code class="literal">
       LAST_ERROR_SEEN
      </code>
     </p>
     <p>
      The timestamp of the most recent error seen from the
              client in the
      <code class="literal">
       IP
      </code>
      column.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The
   <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
    <code class="literal">
     host_cache
    </code>
   </a>
   table has these
          indexes:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      Primary key on (
      <code class="literal">
       IP
      </code>
      )
     </p>
    </li>
    <li class="listitem">
     <p>
      Index on (
      <code class="literal">
       HOST
      </code>
      )
     </p>
    </li>
   </ul>
  </div>
  <p>
   <a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
    <code class="literal">
     TRUNCATE TABLE
    </code>
   </a>
   is permitted for
          the
   <a class="link" href="performance-schema-host-cache-table.html" title="29.12.22.3 The host_cache Table">
    <code class="literal">
     host_cache
    </code>
   </a>
   table. It requires
          the
   <a class="link" href="privileges-provided.html#priv_drop">
    <code class="literal">
     DROP
    </code>
   </a>
   privilege for the
          table. Truncating the table flushes the host cache, which has
          the effects described in
   <a class="xref" href="host-cache.html#host-cache-flushing" title="Flushing the Host Cache">
    Flushing the Host Cache
   </a>
   .
  </p>
 </div>
 <br/>
</div>
