<p>Raised when a client tries to change @@session.sql_log_bin while a transaction is still open.</p>
<p>MySQL Error 1694 ER_INSIDE_TRANSACTION_PREVENTS_SWITCH_SQL_LOG_BIN appears when you attempt to set @@session.sql_log_bin during an active transaction. Commit or roll back the transaction first, then modify the variable.</p>
Cannot modify @@session.sql_log_bin inside a transaction
The server blocks any attempt to change the @@session.sql_log_bin flag while a transaction is in progress. The flag controls whether the current session writes changes to the binary log, so altering it mid-transaction could corrupt replication.
The error is thrown immediately when MySQL detects the SET statement inside a START TRANSACTION block or after an implicit transaction begins.
Binary logs feed replication and point-in-time recovery. Leaving the variable unchanged during a transaction maintains consistency across replicas and backup chains.
Ignoring the error means your session fails to switch logging modes, which can break administrative scripts or cause silent data loss if you proceed assuming logging was disabled.
MySQL automatically starts an implicit transaction for statements such as CREATE TABLE or SELECT ... FOR UPDATE. Issuing SET @@session.sql_log_bin = 0 afterward triggers the error.
Explicit transactions begun with START TRANSACTION or BEGIN and not yet committed also cause the failure when you run a SET statement targeting sql_log_bin.
End the transaction with COMMIT or ROLLBACK, then execute the SET command. If you do not need a transaction, remove START TRANSACTION entirely.
Wrap administrative code that turns binary logging on or off inside autocommit mode to guarantee no open transactions conflict with the variable change.
Automation scripts sometimes disable logging before DML to avoid replication loops. Insert a COMMIT right before disabling the flag.
Stored procedures mixing data changes and maintenance commands must split the logic: finish the modification block, commit, then change sql_log_bin.
Always check @@autocommit and issue COMMIT before toggling binary logging. Use SET SESSION sql_log_bin only in isolated sessions dedicated to maintenance.
Leverage Galaxy’s session-aware editor to highlight open transactions. Galaxy warns you when attempting session-level changes that violate MySQL rules.
Error 1223 – LOCK_WAIT_TIMEOUT: occurs when a transaction holds locks too long. Resolve by optimizing queries or increasing innodb_lock_wait_timeout.
Error 1172 – ER_TRANS_CACHE_FULL: signals the transaction cache is full; break large statements into smaller batches to fix.
The session executes SET @@session.sql_log_bin = 0 after BEGIN but before COMMIT.
MySQL starts an internal transaction for CREATE TABLE; issuing SET afterward raises the error.
Sessions running with autocommit = 0 remain in a permanent transaction until explicitly committed.
Raised when a transaction cannot obtain a lock within the configured timeout.
Occurs when the transaction cache exceeds its memory limit.
Appears when binary logging is disabled despite requirements from replication settings.
Yes, set sql_log_bin system variable in my.cnf and restart, but this affects replication and backups.
Yes, once the transaction ends, MySQL allows changes to sql_log_bin.
Error 1694 exists in MySQL 5.6 and later, including 8.0.
Galaxy highlights open transactions and surfaces MySQL errors instantly, helping you commit before rerunning the SET.