FLUSH

Use this MySQL statement to clear temporary caches in MySQL.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

FLUSH [LOCAL|NO_WRITE_TO_BINLOG] option[,  . . . ]

Explanation

Options:

DES_KEY_FILE, HOSTS, LOGS, PRIVILEGES, QUERY_CACHE,
STATUS, TABLE, TABLES, TABLES WITH READ LOCK, USER_RESOURCES

Use this statement to clear temporary caches in MySQL. It requires RELOAD privileges. Multiple options may be given in a comma-separated list.

To prevent this statement from writing to the binary log file, include the NO_WRITE_TO_BINLOG keyword or its alias, LOCAL. The DES_KEY_FILE option reloads the DES encryption file. HOSTS clears the hosts cache, which is used to minimize host/IP address lookups. The hosts cache may need to be flushed if a host has been blocked from accessing the server. LOGS is used to close all of the logfiles and reopen them. The PRIVILEGES option reloads the grant table for users. This is necessary if the user table in the mysql database is modified manually, without a GRANT statement. QUERY CACHE instructs the server to defragment the query cache. The STATUS option resets the status variables that report information about the caches.

The TABLE option, followed by one or more table names, forces the given tables to be closed. This will terminate any active queries on the given tables. The TABLES option without listing any table names, causes all tables to be closed, all queries to be terminated, and the query cache to be flushed as well. Actually, this option is the same as TABLE with no table name.

Use the TABLES WITH READ LOCK option to close all tables and lock them with a global read lock. This should be considered when dealing with transactional tables and implicit commits of changes. This option will allow users to view the data, but not to update it or to insert records. The lock will remain in place until the UNLOCK TABLES statement is executed.

USER_RESOURCES reset all user resources. You can use this when users have been locked out due to exceeding usage limits.

The mysqladmin utility may be used to execute this statement with several of its options. See for information on this utility.

Two options for this statement have been deprecated: MASTER and SLAVE. RESET MASTER and RESET SLAVE should be used instead.

As of version 5.1 of MySQL, the FLUSH statement cannot be called by a stored function or a trigger. It can be included in a stored procedure, just not called by a stored function or trigger.