datablogs

Replicate_Wild_Ignore_Table vs Replicate_Ignore_DB in MySQL Replication

Replicate_Wild_Ignore_Table vs Replicate_Ignore_DB in MySQL Replication

When configuring MySQL replication, DBAs often need to control which databases or tables should not be replicated to the replica server. MySQL provides several replication filters for this purpose, and two commonly used ones are Replicate_Ignore_DB and Replicate_Wild_Ignore_Table.

Replicate_Ignore_DB

replicate-ignore-db is used to exclude an entire database from replication. When this option is configured on the replica, any changes related to that database will not be applied on the replica server.

Example configuration:

replicate-ignore-db=testdb

In this case, all changes made to the testdb database on the primary server will be ignored by the replica.

However, this option works based on the default database selected using the USE statement. If queries reference tables using fully qualified names (for example db_name.table_name), replication behavior may become inconsistent.

Replicate_Wild_Ignore_Table

replicate-wild-ignore-table allows DBAs to ignore specific tables or patterns of tables during replication. It supports wildcard characters, which makes it more flexible.

Example configuration:

replicate-wild-ignore-table=testdb.logs_%
replicate-wild-ignore-table=%.audit_log

This configuration will ignore:

  • All tables starting with logs_ in testdb

  • Any table named audit_log in any database

Wildcards supported:

  • % -- any number of characters

  • _ -- single character

Key Difference

The main difference is the level of filtering

  • replicate-ignore-db -- filters at the database level

  • replicate-wild-ignore-table -- filters at the table level with wildcard support

Best Practice

For better control and predictable behavior, most DBAs prefer table-level filtering using replicate-wild-ignore-table, especially in environments where cross-database queries are common.

Using the correct replication filter helps maintain efficient replication and ensures only the required data is replicated across servers. 

0 Comments