Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of emptying cache by mysql

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the method of mysql to achieve emptying cache, I hope you will learn a lot after reading this article, let's discuss it together!

Mysql method to clear the cache: use FLUSH syntax to clear the cache. In order to execute FLUSH, you must have reload permission, and the syntax is [FLUSH flush_option [, flush_option]].

Mysql's method to clear the cache:

Clear cach

FLUSH syntax of mysql (clear cache)

FLUSH flush_option [, flush_option]

If you want to clear some MySQL using internal caching, you should use the FLUSH command. In order to execute FLUSH, you must have reload permission.

A flush_option can be anything of the following:

HOSTS is the most frequently used and often encountered. It is mainly used to empty the host cache table. If some of your hosts change the IP number, or if you get an error message Host. Isblocked, you should clear the host table. When connecting to a MySQL server, more than max_connect_errors errors occur continuously for a given host, and MySQL will prevent further connection requests from the host for security reasons. Clearing the host table allows the host to try to connect again.

LOGS closes the current binary log file and creates a new file. The name of the new binary log file adds 1 to the number of the current binary file.

PRIVILEGES is also often used. Whenever a new permission is regranted, it is generally executed to reload the permission from the database authorization table to the cache, just in case, to make the new permission take effect immediately.

TABLES closes all open tables, and this operation clears the contents of the query cache.

FLUSH TABLES WITH READ LOCK closes all open tables and adds a read lock to all tables in the database until unlock tables is executed explicitly, which is often used when backing up data.

STATUS resets most state variables to 0.

MASTER deletes all binary log files in the binary log index file, resets the index file of the binary log file to empty, and creates a new binary log file, but this is no longer recommended and changed to reset master. You can imagine how corny you used to be. You could have done it with a simple command, but you need several commands. The previous practice is to find out the current binary log file name first, and then use purge operation.

QUERY CACHE restructures the query cache to remove fragmentation and improve performance, but does not affect the existing data in the query cache, unlike Flush table and Reset Query Cache (which will empty the contents of the query cache).

SLAVE is similar to reset replication, making the slave database forget the replication location of the master database, and also delete the downloaded relay log. Like Master, it is no longer recommended and changed to Reset Slave. This is also very useful.

Generally speaking, Flush operations are recorded in binary log files, but FLUSH LOGS, FLUSH MASTER, FLUSH SLAVE, and FLUSH TABLES WITH READ LOCK are not recorded, so if the above operations are recorded in binary log files, it will affect the slave database.

Note: the Reset operation actually acts as an enhanced version of the Flush operation.

After reading this article, I believe you have a certain understanding of mysql to achieve emptying cache, want to know more about it, welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report