- MySQL 5.1 Reference Manual :: 12 SQL Statement Syntax :: 12.4 Database Administration Statements :: 12.4.6 Other Administrative Statements :: 12.4.6.3 FLUSH Syntax
-
- MySQL 5.1 Reference Manual
- Preface, Notes, Licenses
- 1 General Information
- 2 Installing and Upgrading MySQL
- 3 Tutorial
- 4 MySQL Programs
- 5 MySQL Server Administration
- 6 Backup and Recovery
- 7 Optimization
- 8 Language Structure
- 9 Internationalization and Localization
- 10 Data Types
- 11 Functions and Operators
- 12 SQL Statement Syntax
- 13 Storage Engines
- 14 High Availability and Scalability
- 15 MySQL Enterprise Monitor
- 16 Replication
- 17 MySQL Cluster NDB 6.X/7.X
- 18 Partitioning
- 19 Stored Programs and Views
- 20 INFORMATION_SCHEMA Tables
- 21 Connectors and APIs
- 22 Extending MySQL
- A MySQL 5.1 Frequently Asked Questions
- B Errors, Error Codes, and Common Problems
- C MySQL Change History
- D Restrictions and Limits
- Index
- Standard Index
- C Function Index
- Command Index
- Function Index
- INFORMATION_SCHEMA Index
- Transaction Isolation Level Index
- JOIN Types Index
- Operator Index
- Option Index
- Privileges Index
- SQL Modes Index
- Status Variable Index
- Statement/Syntax Index
- System Variable Index
FLUSH [NO_WRITE_TO_BINLOG | LOCAL]
flush_option
[,flush_option
] ...The
FLUSH
statement clears or reloads various internal caches used by MySQL. One variant acquires a lock. To executeFLUSH
, you must have theRELOAD
privilege.By default,
FLUSH
statements are written to the binary log so that they will be replicated to replication slaves. Logging can be suppressed with the optionalNO_WRITE_TO_BINLOG
keyword or its aliasLOCAL
.Note
FLUSH LOGS
,FLUSH MASTER
,FLUSH SLAVE
, andFLUSH TABLES WITH READ LOCK
are not written to the binary log in any case because they would cause problems if replicated to a slave.The
RESET
statement is similar toFLUSH
. See Section 12.4.6.6, “RESET
Syntax”, for information about using theRESET
statement with replication.flush_option
can be any of the following items:-
DES_KEY_FILE
Reloads the DES keys from the file that was specified with the
--des-key-file
option at server startup time. -
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 thanhost_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 enables further connection attempts from the host. See Section B.5.2.6, “Host '
”. You can start mysqld withhost_name
' is blocked--max_connect_errors=999999999
to avoid this error message. -
LOGS
Closes and reopens all log files. If binary logging is enabled, the sequence number of the binary log file is incremented by one relative to the previous file. 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 ignoresSIGHUP
andSIGQUIT
).If the server is writing error output to a named file (for example, if it 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 server is not writing to a named file (for example, if it is writing errors to the console). -
MASTER
Deletes all binary logs, resets the binary log index file and creates a new binary log.
FLUSH MASTER
is deprecated in favor ofRESET MASTER
, and is supported for backward compatibility only. See Section 12.5.1.2, “RESET MASTER
Syntax”. -
PRIVILEGES
Reloads the privileges from the grant tables in the
mysql
database. On Unix, this also occurs if the server receives aSIGHUP
signal.The server caches information in memory as a result of
GRANT
,CREATE USER
,CREATE SERVER
, andINSTALL PLUGIN
statements. This memory is not released by the correspondingREVOKE
,DROP USER
,DROP SERVER
, andUNINSTALL PLUGIN
statements, so for a server that executes many instances of the statements that cause caching, there will be an increase in memory use. This cached memory can be freed withFLUSH PRIVILEGES
. -
QUERY CACHE
Defragment the query cache to better utilize its memory.
FLUSH QUERY CACHE
does not remove any queries from the cache, unlikeFLUSH TABLES
orRESET QUERY CACHE
. -
SLAVE
Resets all replication slave parameters, including relay log files and replication position in the master's binary logs.
FLUSH SLAVE
is deprecated in favor ofRESET SLAVE
, and is supported for backward compatibility only. See Section 12.5.2.5, “RESET SLAVE
Syntax”. -
STATUS
This option adds the current thread's session status variable values to the global values and resets the session values to zero. It also resets the counters for key caches (default and named) to zero and sets
Max_used_connections
to the current number of open connections. This is something you should use only when debugging a query. See Section 1.7, “How to Report Bugs or Problems”. -
TABLES
FLUSH TABLES
has several variant forms.FLUSH TABLE
is a synonym forFLUSH TABLES
, except thatTABLE
does not work with theWITH READ LOCK
variant.-
FLUSH TABLES
Closes all open tables, forces all tables in use to be closed, and flushes the query cache.
FLUSH TABLES
also removes all query results from the query cache, like theRESET QUERY CACHE
statement. -
FLUSH TABLES
tbl_name
[,tbl_name
] ...With a list of one or more comma-separated table names, this is like
FLUSH TABLES
with no names except that the server flushes only the named tables. No error occurs if a named table does not exist. -
FLUSH TABLES WITH READ LOCK
Closes all open tables and locks all tables for all databases with a global read lock until you explicitly release the lock by executing
UNLOCK TABLES
. This is a very convenient way to get backups if you have a file system such as Veritas or ZFS 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 asLOCK TABLES
andUNLOCK TABLES
with respect to table locking and implicit commits:UNLOCK TABLES
implicitly commits any active transaction only if any tables currently have been locked withLOCK TABLES
. The commit does not occur forUNLOCK TABLES
followingFLUSH TABLES WITH READ LOCK
because the latter statement does not acquire table locks.Beginning a transaction causes table locks acquired with
LOCK TABLES
to be released, as though you had executedUNLOCK TABLES
. Beginning a transaction does not release a global read lock acquired withFLUSH TABLES WITH READ LOCK
.
FLUSH TABLES WITH READ LOCK
does not prevent the server from inserting rows into the log tables (see Section 5.2.1, “Selecting General Query and Slow Query Log Output Destinations”).
-
-
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 5.5.4, “Setting Account Resource Limits”.
The mysqladmin utility provides a command-line interface to some flush operations, via command such as
flush-hosts
,flush-logs
,flush-privileges
,flush-status
, andflush-tables
.Note
It is not possible in MySQL 5.1 to issue
FLUSH
statements within stored functions or triggers. However, you may useFLUSH
in stored procedures, so long as these are not called from stored functions or triggers. See Section D.1, “Restrictions on Stored Routines, Triggers, and Events”.