MySQL备份中FLUSH命令的用法
MySQL数据库我们在做数据库备份时经常用FLUSH命令,下面总结一下语法。如果服务器使用--log-error选项,则FLUSH LOGS会导致错误日
MySQL数据库我们在做数据库备份时经常用FLUSH命令,下面总结一下语法。
FLUSH语法
FLUSH [LOCAL | NO_WRITE_TO_BINLOG] flush_option [, flush_option] ...
如果您想要清除MySQL使用的部分内部缓存,您应该使用FLUSH语句。要执行FLUSH,您必须拥有RELOAD权限。
flush_option可以为以下的任何一个:
· HOSTS
用于清空主机缓存表。如果有的主机更改了IP号或如果您得到了错误信息Host host_name is blocked,则您应该刷新主机表。当在连接到MySQL服务器时,如果对于一个给定的主机,接连出现错误“多于max_connect_errors”,此时,MySQL会假定出现了错误,并阻止主机后续的连接申请。刷新主机表允许主机尝试再次连接。您可以使用max_connect_errors=999999999启动mysqld,以避免此错误信息。
· DES_KEY_FILE
用于在服务器启动时,从采用--des-key-file选项指定的文件重新载入DES关键字。
· LOGS
用于关闭并重新打开所有的日志文件。如果您已经指定了一个更新日志文件或一个二进制日志文件,同时没有扩展,则相对于前一个文件,日志文件的扩展号增加1。如果您在文件名称中使用了一个扩展,则MySQL会关闭并重新打开日志文件。在Unix中,当相mysqld服务器发送一个SIGHUP信号时,也会如此(例外情况是部分Mac OS X 10.3版本。在这些版本中,mysqld忽略SIGHUP和SIGQUIT)。
如果服务器使用--log-error选项,则FLUSH LOGS会导致错误日志被重命名(使用后缀-old),同时mysqld会创建一个新的空日志文件。如果没有给定--log-error选项,则不会进行重命名。
· PRIVILEGES
用于从mysql数据库中的授权表重新载入权限。
· QUERY CACHE
对查询缓存进行整理碎片,以更好得利用存储器。与RESET QUERY CACHE不同,本语句不会从缓存中取消任何查询。
· STATUS
用于把多数状态变量重新设置为零。只在当调试查询时,您才应该使用此项。
· {TABLE | TABLES} [tbl_name [, tbl_name] ...]
当没有表被命名时,关闭所有打开的表,并迫使所有正在使用的表关闭。这也会刷新查询缓存。此项含有一个或多个表名称,只刷新给定的表。和RESET QUERY CACHE语句一样,FLUSH TABLES还会取消来自查询缓存的所有查询结果。
· TABLES WITH READ LOCK
对于所有带读取锁定的数据库,关闭所有打开的表,并锁定所有的表,直到您执行UNLOCK TABLES为止。如果您拥有一个可以及时进行快照的文件系统,比如Veritas,则这是进行备份的非常方便的方法。
· USER_RESOURCES
用于把所有每小时用户资源重新设置为零。这可以使已经达到了每小时连接、查询或更新限值的客户端立刻重新恢复活性。FLUSH USER_RESOURCES不适用于同时连接的最大限值。FLUSH语句被写入二进制日志,除非使用了自选的NO_WRITE_TO_BINLOG关键字(或其别名LOCAL)。注释:在任何情况下,FLUSH LOGS, FLUSH MASTER, FLUSH SLAVE和FLUSH TABLES WITH READ LOCK都不会被记入日志,因为如果它们被复制到一个从属服务器上,会导致出现问题。
您也可以使用flush-hosts, flush-logs, flush-privileges, flush-status或flush-tables命令访问含有mysqladmin应用程序的语句。
注释:在MySQL 5.1.2-alpha中,不可能在已存储的函数或触发程序中发布FLUSH语句。不过,,您可以在已存储的过程中使用FLUSH,只要它们不会从已存储的函数或触发程序中被调用。
推荐阅读:
MySQL备份还原参数详解
MySQL备份工具mysqldump和mydumper的备份效率比较
MySQL备份恢复“故障”总结
MySQL备份与恢复的三种方法总结

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySql is a commonly used relational database management system that is widely used in various business and application scenarios. For MySQL backup issues, the selection and execution method of the backup plan are crucial. In this article, we will introduce various backup options and how to create and restore MySQL backups efficiently. 1. Selection of backup plan In the process of selecting a MySQL backup plan, you should choose a backup plan that suits you based on the business scenario and actual situation. Cold backup The so-called cold backup is to complete the MySQL database.

How to use MySQL data backup and recovery tools to achieve disaster recovery. Data backup and recovery are a very important part of the database management process. Backing up your data protects your database from accidental corruption, hardware failure, or other catastrophic events. As a popular relational database management system, MySQL provides some powerful tools to achieve data backup and recovery. This article will introduce how to use MySQL's data backup and recovery tools to achieve disaster recovery. MySQL data backup tool-mysql

In the MySQL database, each InnoDB table corresponds to an .ibd file, which stores the table's data and indexes. Therefore, for the management and maintenance of MySQL database, the management of ibd files is also particularly important. This article will introduce how to effectively manage and maintain ibd files in a MySQL database and provide specific code examples. 1. Check and optimize table space First, we can check the disk space usage of the table using the following SQL statement: SELECTTAB

MySQL is one of the most widely used relational database management systems currently. Its efficiency and reliability make it the first choice for many enterprises and developers. But for various reasons, we need to back up the MySQL database. Backing up a MySQL database is not an easy task because once the backup fails, important data may be lost. Therefore, in order to ensure data integrity and recoverability, some measures must be taken to achieve efficient MySQL database backup and recovery. This article will introduce how to achieve

MySQL is a popular relational database that is widely used in various fields. However, like other applications, MySQL has risks such as data corruption, crashes, and malicious attacks. Therefore, backing up your data is crucial. Backups can provide security and some form of "undo" functionality to data, reducing or even eliminating instability and risk. The most common backup types are full backup and incremental backup. However, if you need frequent, real-time backups, rolling backups are a better approach. A rolling backup is when an acceptable

There is no absolutely optimal MySQL database backup and recovery solution, and it needs to be selected based on the amount of data, business importance, RTO and RPO. 1. Logical backup (mysqldump) is simple and easy to use, suitable for small databases, but slow and huge files; 2. Physical backup (xtrabackup) is fast, suitable for large databases, but is more complicated to use. The backup strategy needs to consider the backup frequency (RPO decision), backup method (data quantity and time requirement decision) and storage location (off-site storage is more secure), and regularly test the backup and recovery process to avoid backup file corruption, permission problems, insufficient storage space, network interruption and untested issues, and ensure data security.

Analysis of MySQL database backup and recovery performance tuning project experience In daily operation and maintenance, MySQL database backup and recovery work is indispensable. However, in the face of multi-terabyte or even petabyte-level data scale, the time and resource consumption required for backup and recovery often become key factors restricting database performance. This article will share some practical experiences and techniques through a practical case of backup and recovery performance tuning for a large Internet enterprise. 1. Selection of backup solutions. Based on different business needs and data scale, the selection of backup solutions should also be considered.

MySQL is currently one of the most popular relational database management systems and is widely used in enterprise-level applications. Whether you are a developer or a data administrator, you need to understand the basic knowledge of MySQL backup and recovery. Backup and recovery not only help enterprises protect data, but also enable systems to respond quickly to adverse situations and restore them to normal operating conditions as much as possible. This article will detail the steps for MySQL backup and recovery and provide some best practices to help readers go further in protecting their MySQL databases.
