FLUSH [LOCAL | NO_WRITE_TO_BINLOG]
flush_option [, flush_option] ...
The FLUSH statement clears or reloads
various internal caches used by MySQL. To execute
FLUSH, you must have the
RELOAD privilege.
The RESET statement is similar to
FLUSH. See Section 13.5.5.5, “RESET Syntax”.
flush_option can be any of the
following:
HOSTS
Empties the host cache tables. You should flush the host
tables if some of your hosts change IP number or if you
get the error message Host
'. When more than
host_name' is
blockedmax_connect_errors errors occur
successively for a given host while connecting to the
MySQL server, MySQL assumes that something is wrong and
blocks the host from further connection requests. Flushing
the host tables allows the host to attempt to connect
again. See Section A.1.2.5, “Host '”. You can start
mysqld with
host_name' is
blocked--max_connect_errors=999999999 to avoid
this error message.
DES_KEY_FILE
Reloads the DES keys from the file that was specified with
the --des-key-file option at server
startup time.
LOGS
Closes and reopens all log files. If you have specified an
update log file or a binary log file without an extension,
the extension number of the log file is incremented by one
relative to the previous file. If you have used an
extension in the file name, MySQL closes and reopens the
update log or binary log file. See
Section 5.11.4, “The Binary Log”. On Unix, this is the same
thing as sending a SIGHUP signal to the
mysqld server (except on some Mac OS X
10.3 versions where mysqld ignores
SIGHUP and SIGQUIT).
Beginning with MySQL 4.0.10, if the server was started
with the --log-error option,
FLUSH LOGS causes it to rename the
current error log file with a suffix of
-old and create a new empty log file.
No renaming occurs if the --log-error
option was not given.
MASTER
(DEPRECATED). Deletes all binary
logs, resets the binary log index file and creates a new
binary log. FLUSH MASTER is deprecated
in favor of RESET MASTER, and is
supported for backwards compatibility only. See
Section 13.6.1.2, “RESET MASTER Syntax”.
PRIVILEGES
Reloads the privileges from the grant tables in the
mysql database.
QUERY CACHE
Defragment the query cache to better utilize its memory.
FLUSH QUERY CACHE does not remove any
queries from the cache, unlike RESET QUERY
CACHE.
SLAVE
(DEPRECATED). Resets all replication
slave parameters, including relay log files and
replication position in the master's binary logs.
FLUSH SLAVE is deprecated in favour of
RESET SLAVE, and is supported for
backwards compatibility only. See
Section 13.6.2.5, “RESET SLAVE Syntax”.
STATUS
Resets most status variables to zero. This is something you should use only when debugging a query. See Section 1.8, “How to Report Bugs or Problems”.
{TABLE | TABLES}
[
tbl_name [,
tbl_name] ...]
When no tables are named, closes all open tables and
forces all tables in use to be closed. This also flushes
the query cache. With one or more table names, flushes
only the given tables. FLUSH TABLES
also removes all query results from the query cache, like
the RESET QUERY CACHE statement.
TABLES WITH READ LOCK
Closes all open tables and locks all tables for all
databases with a read lock until you explicitly release
the lock by executing UNLOCK TABLES.
This is very convenient way to get backups if you have a
filesystem such as Veritas that can take snapshots in
time.
FLUSH TABLES WITH READ LOCK acquires a
global read lock and not table locks, so it is not subject
to the same behavior as LOCK TABLES and
UNLOCK TABLES with respect to table
locking and implicit commits:
UNLOCK TABLES commits a transaction
only if any tables currently have been locked with
LOCK TABLES. This does not occur
for UNLOCK TABLES following
FLUSH TABLES WITH READ LOCK because
the latter statement does not acquire table-level
locks.
Beginning a transaction causes table locks acquired
with LOCK TABLES to be released, as
though you had executed UNLOCK
TABLES. Beginning a transaction does not
release a global read lock acquired with
FLUSH TABLES WITH READ LOCK.
USER_RESOURCES
Resets all per-hour user resources to zero. This enables
clients that have reached their hourly connection, query,
or update limits to resume activity immediately.
FLUSH USER_RESOURCES does not apply to
the limit on maximum simultaneous connections. See
Section 13.5.1.2, “GRANT Syntax”.
Before MySQL 4.1.1, FLUSH statements are
not written to the binary log. As of MySQL 4.1.1, they are
written to the binary log unless the optional
NO_WRITE_TO_BINLOG keyword (or its alias
LOCAL) is used. This is done so that
FLUSH statements used on a MySQL server
acting as a replication master will be replicated by default
to the replication slave.
Note: FLUSH
LOGS, FLUSH MASTER,
FLUSH SLAVE, and FLUSH TABLES WITH
READ LOCK are not logged in any case because they
would cause problems if replicated to a slave.
You can also access some of these statements with the
mysqladmin utility, using the
flush-hosts, flush-logs,
flush-privileges,
flush-status, or
flush-tables commands.
See also Section 13.5.5.5, “RESET Syntax”, for information about how
the RESET statement is used with
replication.

User Comments
Add your own comment.