content_image/853985.jpg
the group_replication_applier  or group_replication_recovery channels. 

This option affects only statements that apply to tables. It does not affect statements that apply only to other database objects, such as stored routines. To filter statements operating on stored routines, use one or more of the --replicate-*-db  options. 

• --replicate-rewrite-db= from_name -> to_name 

<img src='content_image/853985.jpg'>

Tells the replica to create a replication filter that translates the specified database to to_name  if it was from_name  on the source. Only statements involving tables are affected, not statements such as CREATE DATABASE , DROP DATABASE , and ALTER DATABASE . 

To specify multiple rewrites, use this option multiple times. The server uses the first one with a from_name  value that matches. The database name translation is done before  the --replicate- *  rules are tested. You can also create such a filter by issuing a CHANGE REPLICATION FILTER REPLICATE_REWRITE_DB  statement. 

If you use the --replicate-rewrite-db  option on the command line and the >  character is special to your command interpreter, quote the option value. For example: 

shell> mysqld --replicate-rewrite-db=" olddb -> newdb " 

The effect of the --replicate-rewrite-db  option differs depending on whether statement-based or row-based binary logging format is used for the query. With statement-based format, DML statements are translated based on the current database, as specified by the USE  statement. With row-based format, DML statements are translated based on the database where the modified table exists. DDL statements are always filtered based on the current database, as specified by the USE  statement, regardless of the binary logging format. 

To ensure that rewriting produces the expected results, particularly in combination with other replication filtering options, follow these recommendations when you use the --replicate-rewrite-db  option: 

•Create the from_name  and to_name  databases manually on the source and the replica with different names. 

•If you use statement-based or mixed binary logging format, do not use cross-database queries, and do not specify database names in queries. For both DDL and DML statements, rely on the USE  statement to specify the current database, and use only the table name in queries. 

•If you use row-based binary logging format exclusively, for DDL statements, rely on the USE  statement to specify the current database, and use only the table name in queries. For DML statements, you can use a fully qualified table name ( db . table ) if you want. 

If these recommendations are followed, it is safe to use the --replicate-rewrite-db  option in combination with table-level replication filtering options such as --replicate-do-table . 

This option supports channel specific replication filters, enabling multi-source replicas to use specific filters for different sources. Specify the channel name followed by a colon, followed by the filter specification. The first colon is interpreted as a separator, and any subsequent colons are interpreted 

