Mysql binary log Filter

Source: Internet
Author: User


Mysql binary LOG filter can use two options to filter statements from binary logs: binlog-do-db and binlog-ignore-db www.2cto.com, binlog-do-db uses binlog-do-db = db_name. With this option, the master server determines whether the current database (that is, the database selected for USE) is db_name. If yes, the updates are recorded in the binary log. After use, all other databases that are not explicitly specified will be ignored. If this option is used, make sure that only the current database is updated. There are two databases on my server: db_factory and db_user. Before using this option, update operations on both databases are immediately copied to the slave database, but after www.2cto.com [SQL] binlog-do-db = db_factory is set, changes to db_user are not copied from the database. Therefore, you are advised not to set this option if you do not have special requirements. Of course, if it is a database that is often updated, and the others are the same local database, it can be used as an optimization method without subsequent operations of binary logs. Note that if binlog-do-db = db_factory is set. However, the following statement will be used later: [SQL] use db_user insert into db_factory.employ ...... at this time, updates will not be received by binary logs. 2. binlog-ignore-db indicates the option to copy other databases while ignoring a specific database. In fact, the above option indicates "ignore other databases, only record me into logs", and this option can be used to table "ignore me, record logs for other databases ", the usage of this option can be as follows: www.2cto.com [SQL] [mysqld] binlog-ignore-db = db_factory binlog-ignore-db = db_user. Of course, the above binlog-do-db can also be used to record multiple tables for multiple times. write binary logs. Iii. do the option rules have binlog-do-db or binlog-ignore-db rules? No: Write the statement to the binary log and exit. Yes: Perform the next step. There are some rules (binlog-do-db or binlog-ignore-db or both ). There is a database, that is, whether to USE the USE command to select a database? No: Do not write the statement and exit. Yes: Perform the next step. Www.2cto.com has the current database. Is there any binlog-do-db rule? Yes: Does the current database match the binlog-do-db rule? If yes, write and exit. If not, do not write and exit. No: Perform the next step. There are some binlog-ignore-db rules. Does the current database match the binlog-ignore-db rule? Yes: Do not write the statement and exit. No: Write query and exit. As shown in the preceding process logic, if binlog-do-db is set, binlog-ignore-db will be ignored. In addition, during the application of these two options, it is important to note that the current database is selected through USE.

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.