MySQL flush command is used to clean up the internal caches used by MySQL and only the root level user can have a permissions for a FLUSH command.
The FLUSH command syntax:
The most common options for FLUSH command are:
- PRIVILEGES
- TABLES
- HOSTS
- LOGS
1. Flush PRIVILEGES
FLUSH PRIVILEGES command can be used before and after adding new users.This command simply reloads the grant tables in your MySQL database by enabling the changes to take effect without stopping and restarting MySQL.
FLUSH PRIVILEGES command returns the Query OK response means that the cleaning process occurred without a problem.
2. Flush TABLES
The FLUSH TABLES command closes all tables currently open or in use.
When your caches are empty, MySQL can better utilize available memory.
Again, you will get response like the Query OK response after using FLUSH TABLES command.
Again, you will get response like the Query OK response after using FLUSH TABLES command.
3. Flush HOSTS
The FLUSH HOSTS command used specifically with the host cache tables.
If you are unable to connect to your MySQL server, a most common reason is that the maximum number of connections has been reached for a particular host so its throwing errors.
When MySQL gets numerous errors on connection, it assumes something is missing and its just blocks any additional connection attempts to that particular host. The FLUSH HOSTS command resets this process and again allows to connect to that particular HOST.
4. Flush LOGS
The FLUSH LOGS MySQL command closes and reopens all log files.Sometimes size of logfile is too big and to open or reload that files can take much time so if you want to start a new one so FLUSH LOGS command will create a new empty log file.
Here I have explained some basics and most useful FLUSH commands whereas MySQL have total nine FLUSH commands.
0 comments:
Post a Comment