A Useful GTID Feature for Migrating to MySQL GTID Replication – ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS

December 28, 2022
Author
Gaurav Pareek
Share this Post:

Migrating to MySQL GTID ReplicationIn managed services, we get requests to migrate from traditional to GTID-based replication. However, the customer does not want to first enable the GTID on the source node (production). Before MySQL 8.0.23, replication from the disabled GTID source to an enabled GTID replica was impossible.

In this blog, I will talk about a new MySQL feature introduced in 8.0.23, which allows MySQL to replicate from a GTID-disabled source to GTID-enabled replica. You can enable GTID assignment on a replication channel using the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS.

Note: The replica must have gtid_mode=ON set, which cannot be changed afterward unless you remove the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS setting. 

Acceptable inputs

OFF: As the name suggests, it keeps this feature turned off 

Local: Returns the local server UUID, same as server_uuid global variable

UUID: Specify a valid UUID which will be used while generating GTID transactions

Syntax 

Let’s demonstrate the feature  ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS.

Initially, we keep the GTID replication disabled on the source and replica node.

Source: GTID replication is disabled 

Replica: GTID replication disabled

Let’s create a table on the source and check binlog events.  

Replica: binlog events on replica node

Let’s enable the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS=local on the replica and insert a record.

Note: Make sure that gtid_mode=on before enabling the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS=local

Replica Node:

You can see the binlog has server UUID in replica binlogs. I hope this blog post will help you migrate to GTID replication even easier.

Reference:

https://dev.mysql.com/doc/refman/8.0/en/replication-gtids-assign-anon.html

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved