<p>Raised when @@GLOBAL.GTID_PURGED is assigned while GTID mode is disabled.</p>
<p>ER_CANT_SET_GTID_PURGED_WHEN_GTID_MODE_IS_OFF appears in MySQL when you execute SET @@GLOBAL.GTID_PURGED while @@GLOBAL.GTID_MODE=OFF. Turn GTID_MODE to ON or omit the statement to resolve the error.</p>
@@GLOBAL.GTID_PURGED can only be set when
MySQL throws error 1839 with the message "@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_MODE = ON" if you attempt to manipulate the GTID_PURGED variable while global transaction ID (GTID) mode is turned off.
The error blocks the statement to protect replication consistency, because GTID_PURGED defines previously executed transaction identifiers and must align with GTID infrastructure.
The primary cause is running SET @@GLOBAL.GTID_PURGED while @@GLOBAL.GTID_MODE=OFF. This often happens during backups, restores, or server provisioning tasks where GTID settings were not enabled beforehand.
The error can also be triggered by automation scripts that force GTID_PURGED on servers still configured for traditional binary-log position replication.
Enable GTID mode at startup or dynamically, then rerun the SET statement. If you do not need GTID replication, simply remove the GTID_PURGED assignment.
Always confirm that all replicas in the topology use the same GTID configuration before toggling the setting to avoid replication breaks.
During a logical restore produced by mysqldump with --set-gtid-purged=ON, the import fails on a non-GTID server. Re-dump with --set-gtid-purged=OFF or enable GTIDs on the target.
When cloning a replica, administrators may pre-seed GTID_PURGED to skip executed transactions. Turn on GTID_MODE before seeding or use CHANGE MASTER TO MASTER_AUTO_POSITION=0.
Standardize server builds so GTID settings are identical across environments. Use configuration management to enforce gtid_mode, enforce_gtid_consistency, and log_slave_updates.
Test backup and restore procedures in staging with the exact GTID settings used in production. Automate validation with SHOW GLOBAL VARIABLES LIKE 'gtid_mode'.
Error 1840 (ER_GTID_PURGED_WAS_CHANGED): Indicates that GTID_PURGED was changed manually after transactions executed. Ensure GTID_PURGED is set only on a new server.
Error 1782 (ER_GTID_MODE_REQUIRED): Raised when START SLAVE is issued but GTID_MODE is OFF while replication requires it. Enable GTID_MODE or use file/position replication.
Server variable gtid_mode is OFF or OFF_PERMISSIVE when you attempt to set GTID_PURGED.
mysqldump created a script with SET @@GLOBAL.GTID_PURGED but you import it on a non-GTID server.
Primary uses GTID but a newly added replica was installed with GTID support disabled.
Occurs when GTID_PURGED is altered after data has been written. Fix by resetting or restoring on a fresh instance.
Raised when GTID-only operations run while GTID_MODE is OFF. Resolve by enabling GTID mode.
START SLAVE fails because GTID_MODE is OFF but master auto-positioning is requested. Enable GTIDs or disable auto-positioning.
Yes. Starting with MySQL 8.0 you can switch from OFF to ON dynamically using SET GLOBAL commands, provided you follow the ON_PERMISSIVE intermediate state.
Only on a new instance with no prior transactions. Setting it on an active server may corrupt replication metadata.
Rerun mysqldump with --set-gtid-purged=OFF or manually remove the SET @@GLOBAL.GTID_PURGED statement before importing.
Galaxy's SQL editor highlights server variables and flags GTID inconsistencies before execution, reducing the chance of running invalid SET commands.