jump to navigation

Using Mysql’s FLUSH Command December 24, 2012

Posted by Tournas Dimitrios in Mysql.

Mysql’s FLUSH statement has several variant forms (options) that clears or reloads various internal caches , flush tables , or acquire locks . Users with reload privileges on a database can use this command to clean up the internal caches on that specific database . Usually , only the root-level user has the proper permissions to issue RELOAD administrative commands (FLUSH) . Common options for the FLUSH command are :

  • PRIVILEGES : Probably the most known option , it simply reloads the grant tables in your MySQL database , enabling the changes to take effect without stopping and restarting MySQL . When you issue a FLUSH PRIVILEGES command , a “Query OK ” response verifies that the new privileges have  taken place .
    mysql> flush privileges ;
  • HOSTS : This option works specifically with the host cache tables . If MySQL server , has reached the maximum number of connections for a particular host , it’s throwing errors , and simply block any additional connection attempts to that host .The “FLUSH HOSTS” command will reset this process and again allow connections to be made .
    mysql> flush hosts ;
  • TABLES : This option , will close all tables currently open or in use and essentially forces all tables in use to be closed by MySQL  . This is a very convenient way to get backups . Read also , How FLUSH TABLES works in MySQL .
    mysql> flush tables ;
  • LOGS : This option closes and reopens all log files , If the size of these files is getting to large (files mysql.log and mysql.err) , and you want to start a new ones , let’s say during a debugging  process . Starting from  clean (empty) log files can help focus on that specific task . The following command will create  new , empty log files .
    mysql> flush logs ;


The manual has more options listed , these four aforementioned options are certainly a must known “tool-set” .




1. Carol - January 7, 2013

good post. thank for sharing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s