MySQL flush syntax

Source: Internet
Author: User
Tags ip number

Today I carefully read the flush syntax and often use the flush command at work. Here I will summarize it. MySQL flush syntax (clear or reload internal cache) flush flush_option [, flush_option]. If you want to clear some MySQL instances using internal cache, you should use the flush command. To execute flush, you must have the reload permission.

Flush_option can be any of the following:

Hosts is used most often. It is mainly used to clear the host cache table. If some of your hosts change the IP number, or if you get the error message host... isblocked, you should clear the host table. When connecting to the MySQL server, more than max_connect_errors errors occur continuously on a given host. For security purposes, MySQL will block further connection requests from the host. Clear the host table to allow the host to try again.

Logs closes the current binary log file and creates a new file. The new binary log file name is added to the number of the current binary file by 1.
 
Privileges is also frequently used. Every time a new permission is granted, the new permission takes effect immediately just in case. The purpose is to re-load the permission from the database authorization table to the cache.
 
Close all opened tables in tables. This operation also clears the content in the query cache.

Flush tables with read lock disables all opened tables and adds a read lock to all tables in the database until unlock tables is executed explicitly. This operation is often used for data backup.
 
Status resets most status variables to 0.

The master node deletes the binary log files in all binary log index files, resets the index file of the binary log file to null, and creates a new binary log file. However, this is not recommended, changed to reset master. As you can imagine, I used to have a lot of soil. I could have done it with a simple command, but I needed several commands. In the past, I first checked out the current binary log file name, use purge.

Query cache reassembles the query cache to eliminate fragments and improve performance, but does not affect the query cache's existing data. This point is flush table and reset query cache (the query cache content will be cleared) different.

Slave is similar to Resetting replication, so that the slave database forgets the replication location of the master database, and also deletes the downloaded relay log. Like the master database, it is not recommended to use it anymore, changed to reset slave. This is also useful.

Generally, flush operations are recorded in binary log files, but flush logs, flush master, flush slave, and flush tables with read lock are not recorded, therefore, if the above operations are recorded in a binary log file, they will affect the slave database. Note: The reset operation actually plays an enhanced version of the flush operation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.