执行flush命令会默认写入二进制日志,以便能够把该操作的状态同步到Slave,如果不想写入二进制日志,则加上NO_WRITE_TO_BINLOG或其别名LOCAL参数。
注:FLUSH LOGS、FLUSH TABLES WITH READ LOCK (with or without a table list)、FLUSH TABLES tbl_name ... FOR EXPORT在任何情况下都不会写入到二进制日志,因为如果这些命令同步到Slave可能会导致一些问题。
flush_option:
DES_KEY_FILE:重新加载下次MySQL启动时的DES加密值。
HOSTS:清空主机名缓存。如果某个主机名IP地址换了或者出现以下错误信息
Host 'host_name' is blocked
就要执行flush hosts;命令来清空主机缓存。
如果一个连接请求的次数超过 max_connect_errors参数所指定的值,那么MySQL就会禁止该连接,执行flush hosts;命令来清空主机缓存即可。max_connect_errors默认的值是10.
flush tables|table命令会关闭所有的表,并清空所有查询缓存。reset query cache也是清空缓存的。在MySQL 5.6,如果有一张表被加了读锁(lock tables ... read),则不能使用flush tables命令,只能使用flush tables table_name ... with read lock;
flush tables table_name [,table_name] ...
关闭指定的表并清空指定表的缓存,如果该表不存在不会报错。
FLUSH TABLES WITH READ LOCK
FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK
FLUSH TABLES tbl_name [, tbl_name] ... FOR EXPORT
While any of these statements is in effect within the session, attempts to use FLUSH TABLES ... FOR EXPORT produce an error:
FLUSH TABLES ... WITH READ LOCK
FLUSH TABLES ... FOR EXPORT
LOCK TABLES ... READ
LOCK TABLES ... WRITE
While FLUSH TABLES ... FOR EXPORT is in effect within the session, attempts to use any of these statements produce an error:
FLUSH TABLES WITH READ LOCK
FLUSH TABLES ... WITH READ LOCK
FLUSH TABLES ... FOR EXPORT