MySQL Replication


This is the MySQL Replication extract from the MySQL 5.7 Reference Manual.

For legal information, see the Legal Notices.

For help with using MySQL, please visit the MySQL Forums, where you can discuss your issues with other MySQL users.

Document generated on: 2024-07-23 (revision: 79102)

Table of Contents

Preface and Legal Notices
1 Replication
2 Configuring Replication
2.1 Binary Log File Position Based Replication Configuration Overview
2.2 Setting Up Binary Log File Position Based Replication
2.2.1 Setting the Replication Source Configuration
2.2.2 Creating a User for Replication
2.2.3 Obtaining the Replication Source's Binary Log Coordinates
2.2.4 Choosing a Method for Data Snapshots
2.2.5 Setting Up Replicas
2.2.6 Adding Replicas to a Replication Topology
2.3 Replication with Global Transaction Identifiers
2.3.1 GTID Format and Storage
2.3.2 GTID Life Cycle
2.3.3 GTID Auto-Positioning
2.3.4 Setting Up Replication Using GTIDs
2.3.5 Using GTIDs for Failover and Scaleout
2.3.6 Restrictions on Replication with GTIDs
2.3.7 Stored Function Examples to Manipulate GTIDs
2.4 Changing Replication Modes on Online Servers
2.4.1 Replication Mode Concepts
2.4.2 Enabling GTID Transactions Online
2.4.3 Disabling GTID Transactions Online
2.4.4 Verifying Replication of Anonymous Transactions
2.5 MySQL Multi-Source Replication
2.5.1 Configuring Multi-Source Replication
2.5.2 Provisioning a Multi-Source Replica for GTID-Based Replication
2.5.3 Adding GTID-Based Sources to a Multi-Source Replica
2.5.4 Adding a Binary Log Based Source to a Multi-Source Replica
2.5.5 Starting Multi-Source Replicas
2.5.6 Stopping Multi-Source Replicas
2.5.7 Resetting Multi-Source Replicas
2.5.8 Multi-Source Replication Monitoring
2.6 Replication and Binary Logging Options and Variables
2.6.1 Replication and Binary Logging Option and Variable Reference
2.6.2 Replication Source Options and Variables
2.6.3 Replica Server Options and Variables
2.6.4 Binary Logging Options and Variables
2.6.5 Global Transaction ID System Variables
2.7 Common Replication Administration Tasks
2.7.1 Checking Replication Status
2.7.2 Pausing Replication on the Replica
2.7.3 Skipping Transactions
3 Replication Solutions
3.1 Using Replication for Backups
3.1.1 Backing Up a Replica Using mysqldump
3.1.2 Backing Up Raw Data from a Replica
3.1.3 Backing Up a Source or Replica by Making It Read Only
3.2 Handling an Unexpected Halt of a Replica
3.3 Using Replication with Different Source and Replica Storage Engines
3.4 Using Replication for Scale-Out
3.5 Replicating Different Databases to Different Replicas
3.6 Improving Replication Performance
3.7 Switching Sources During Failover
3.8 Setting Up Replication to Use Encrypted Connections
3.9 Semisynchronous Replication
3.9.1 Semisynchronous Replication Administrative Interface
3.9.2 Semisynchronous Replication Installation and Configuration
3.9.3 Semisynchronous Replication Monitoring
3.10 Delayed Replication
4 Replication Notes and Tips
4.1 Replication Features and Issues
4.1.1 Replication and AUTO_INCREMENT
4.1.2 Replication and BLACKHOLE Tables
4.1.3 Replication and Character Sets
4.1.4 Replication and CHECKSUM TABLE
4.1.5 Replication of CREATE ... IF NOT EXISTS Statements
4.1.6 Replication of CREATE TABLE ... SELECT Statements
4.1.8 Replication of CURRENT_USER()
4.1.9 Replication of DROP ... IF EXISTS Statements
4.1.10 Replication with Differing Table Definitions on Source and Replica
4.1.11 Replication and DIRECTORY Table Options
4.1.12 Replication and Floating-Point Values
4.1.13 Replication and Fractional Seconds Support
4.1.14 Replication and FLUSH
4.1.15 Replication and System Functions
4.1.16 Replication of Invoked Features
4.1.17 Replication and LIMIT
4.1.18 Replication and LOAD DATA
4.1.19 Replication and max_allowed_packet
4.1.20 Replication and MEMORY Tables
4.1.21 Replication of the mysql System Database
4.1.22 Replication and the Query Optimizer
4.1.23 Replication and Partitioning
4.1.24 Replication and REPAIR TABLE
4.1.25 Replication and Reserved Words
4.1.26 Replication and Source or Replica Shutdowns
4.1.27 Replica Errors During Replication
4.1.28 Replication and Server SQL Mode
4.1.29 Replication and Temporary Tables
4.1.30 Replication Retries and Timeouts
4.1.31 Replication and Time Zones
4.1.32 Replication and Transaction Inconsistencies
4.1.33 Replication and Transactions
4.1.34 Replication and Triggers
4.1.35 Replication and TRUNCATE TABLE
4.1.36 Replication and User Name Length
4.1.37 Replication and Variables
4.1.38 Replication and Views
4.2 Replication Compatibility Between MySQL Versions
4.3 Upgrading a Replication Topology
4.4 Troubleshooting Replication
4.5 How to Report Replication Bugs or Problems
5 Replication Implementation
5.1 Replication Formats
5.1.1 Advantages and Disadvantages of Statement-Based and Row-Based Replication
5.1.2 Usage of Row-Based Logging and Replication
5.1.3 Determination of Safe and Unsafe Statements in Binary Logging
5.2 Replication Channels
5.2.1 Commands for Operations on a Single Channel
5.2.2 Compatibility with Previous Replication Statements
5.2.3 Startup Options and Replication Channels
5.2.4 Replication Channel Naming Conventions
5.3 Replication Threads
5.3.1 Monitoring Replication Main Threads
5.3.2 Monitoring Replication Applier Worker Threads
5.4 Relay Log and Replication Metadata Repositories
5.4.1 The Relay Log
5.4.2 Replication Metadata Repositories
5.5 How Servers Evaluate Replication Filtering Rules
5.5.1 Evaluation of Database-Level Replication and Binary Logging Options
5.5.2 Evaluation of Table-Level Replication Options
5.5.3 Interactions Between Replication Filtering Options