FLUSH
Syntax
FLUSH [NO_WRITE_TO_BINLOG | LOCAL] flush_option [, flush_option] ...
or when flushing tables:
FLUSH [NO_WRITE_TO_BINLOG | LOCAL] TABLES [table_list] [table_flush_option]
where table_list is a list of tables separated by ,
Description
The FLUSH
statement clears or reloads various internal caches used by
MariaDB. To execute FLUSH
, you must have the RELOAD
privilege. See GRANT
.
The RESET
statement is similar to FLUSH
. See
RESET
.
You cannot issue a FLUSH statement from within a stored function or a trigger. Doing so within a stored procedure is permitted, as long as it is not called by a stored function or trigger. See Stored Routine Limitations, Stored Function Limitations and Trigger Limitations.
If a listed table is a view, an error like the following will be produced:
ERROR 1347 (HY000): 'test.v' is not BASE TABLE
By default, FLUSH
statements are written to the binary log and will be replicated. The NO_WRITE_TO_BINLOG
keyword (LOCAL
is an alias) will ensure the statement is not written to the binary log.
The different flush options are:
Option | Description |
---|---|
CHANGED_PAGE_BITMAPS | Internal command used for backup purposes. See the Information Schema CHANGED_PAGE_BITMAPS Table. |
CLIENT_STATISTICS | Reset client statistics (see SHOW CLIENT_STATISTICS ). |
DES_KEY_FILE | Reloads the DES key file (Specified with the --des-key-file startup option ). |
HOSTS | Flush the hostname cache (used for converting ip to host names and for unblocking blocked hosts. See max_connect_errors ) |
INDEX_STATISTICS | Reset index statistics (see SHOW INDEX_STATISTICS ). |
| Close and reopen the specified log type, or all log types if none are specified. FLUSH RELAY LOGS [connection-name] can be used to flush the relay logs for a specific connection. Only one connection can be specified per FLUSH command. See Multi-source replication. FLUSH ENGINE LOGS will delete all unneeded Aria redo logs. |
MASTER | Deprecated option, use RESET MASTER instead. |
PRIVILEGES | Reload all privileges from the privilege tables in the mysql database. |
QUERY CACHE | Defragment the query cache to better utilize its memory. If you want to reset the query cache, you can do it with RESET QUERY CACHE . |
QUERY_RESPONSE_TIME | See the QUERY_RESPONSE_TIME plugin. |
SLAVE | Deprecated option, use RESET SLAVE instead. |
SSL | (since 10.4.1) Reload server's SSL certificate, private key, CA certificate, CRL PEM files. This is useful to e.g replace certificate that is about to be expired, without restarting the server. See ssl_cert , ssl_key , ssl_ca , ssl_crl options. |
STATUS | Resets all status variables that can be reset to 0 |
TABLE | Close table given as options or all open tables if no table list was used. |
TABLES | Same as FLUSH TABLE . |
TABLES ... FOR EXPORT | For InnoDB tables, flushes table changes to disk to permit binary table copies while the server is running. Introduced in MariaDB 10.0.8. See FLUSH TABLES ... FOR EXPORT for more. |
TABLES WITH READ LOCK | Closes all open tables. New tables are only allowed to be opened with read locks until an UNLOCK TABLES is given. |
TABLES WITH READ LOCK AND DISABLE CHECKPOINT | As TABLES WITH READ LOCK but also disable all checkpoint writes by transactional table engines. This is useful when doing a disk snapshot of all tables. |
TABLE_STATISTICS | Reset table statistics (see SHOW TABLE_STATISTICS ). |
USER_RESOURCES | Resets all per hour user resources. This enables clients that have exhausted their resources to connect again. |
USER_STATISTICS | Reset user statistics (see SHOW USER_STATISTICS ). |
You can also use the mysqladmin
client to flush things. Use mysqladmin --help
to examine what flush commands it supports.
Example
To flush some of the global caches that take up memory, you can do:
FLUSH LOCAL HOSTS, QUERY CACHE, TABLE_STATISTICS, INDEX_STATISTICS, USER_STATISTICS;