The host_cache Table


The host_cache table provides access to the contents of the host cache, which contains client host name and IP address information and is used to avoid DNS lookups. (See , "DNS Lookup Optimization and the Host Cache".) The host_cache table exposes the contents of the host cache so that it can be examined using SELECT statements. The Performance Schema must be enabled or this table is empty.

The server handles rows in the host_cache table like this:

  1. When the first TCP client connection reaches the server from a given IP address, a new host_cache row is created with the IP column set to the client IP, HOST set to NULL, and HOST_VALIDATED set to NO. This row is also used for subsequent client connections from the same originating IP.
  2. If HOST_VALIDATED column for the client IP row is NO, the server attempts an IP-to-host name DNS resolution. If that is successful, the HOST column is updated with the resolved host name and HOST_VALIDATED is set to YES. If resolution is unsuccessful, the action taken depends on whether the error is permanent or transient. For permanent failures, the HOST column is NULL and HOST_VALIDATED is set to YES. For transient failures, the HOST and HOST_VALIDATED columns remain unchanged. (Another DNS resolution attempt occurs the next time a client connects from this IP.)
  3. If an error occurs while processing an incoming client connection from a given IP address, the server updates the corresponding COUNT_XXX_ERRORS statistics columns in the row for that IP. The kinds of errors accounted for are indicated by the column descriptions.

FLUSH HOSTS and TRUNCATE TABLE host_cache have the same effect: They clear the host cache. This also empties the and empty the contents of the host_cache table (because it is the visible representation of the cache) and unblocks any blocked hosts (see "Host 'host_name' is blocked".) FLUSH HOSTS requires the RELOAD privilege. TRUNCATE TABLE requires the DROP privilege for the host_cache table.

The host_cache table has these columns:

The host_cache table was added in MariaDB 5.6.5.

Retornar