What is the usage of ‘flush’ in MySQL?
In MySQL, the FLUSH command is used to refresh various caches in MySQL, making them take effect immediately.
There are various ways to use the FLUSH command, here are some common examples:
- FLUSH TABLES – Refresh all open tables to take immediate effect. This will reload all cached table structures and index information, but will not clear any data.
- Reload the specified table to take effect immediately.
- RELOAD PRIVILEGES – Reload the authorization table to make new authorization rules take immediate effect.
- RESTART LOGS – Close and reopen all log files to immediately activate changes. This is particularly useful when log files become too large and need to be split.
- RESET SERVER STATUS – Refreshes server status information immediately.
- Clear all blocked hosts to immediately restore access permissions.
- Flush query cache – clear the query cache to take effect immediately. This will result in the next query being re-executed instead of using the cache.