SyntaxStudy
Sign Up
MySQL GTID-Based Replication
MySQL Advanced 5 min read

GTID-Based Replication

GTID Replication

Global Transaction Identifiers (GTIDs) uniquely identify every committed transaction. GTID-based replication does not require tracking log file positions.

Example
-- my.cnf (primary and replica)
-- gtid_mode             = ON
-- enforce_gtid_consistency = ON
-- log_bin               = ON
-- binlog_format         = ROW
-- On replica:
CHANGE REPLICATION SOURCE TO
  SOURCE_HOST="primary",
  SOURCE_USER="replicator",
  SOURCE_PASSWORD="pass",
  SOURCE_AUTO_POSITION=1;  -- GTID auto-positions
START REPLICA;
SHOW VARIABLES LIKE "gtid_executed";
Pro Tip

GTID replication makes failover easier — replicas can resync without manual log position tracking.