mysql命令:set sql_log_bin=on/off

本文介绍如何使用 MySQL 的 set sql_log_bin 命令来控制 bin-log 日志的记录状态,包括临时禁用日志记录以避免不需要的复制行为。需要注意的是,在当前会话中设置该变量仅影响当前会话,并且当全局设置该变量时,只会影响新启动的会话。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

对于数据库的操作,经常需要暂时停止对bin-log日志的写入,那就需要这个命令:set sql_log_bin=on/off

参考:dev.mysql.com/doc/refman/5.5/en/set-sql-log-bin.html

13.4.1.3 SET sql_log_bin Syntax

SET sql_log_bin = {0|1}

The sql_log_bin variable controls whether logging to the binary log is done. The default value is 1 (do logging). To change logging for the current session, change the session value of this variable. The session user must have theSUPER privilege to set this variable. Set this variable to 0 for a session to temporarily disable binary logging while making changes to the master which you do not want to replicate to the slave.

As of MySQL 5.5, sql_log_bin can be set as a global or session variable. Setting sql_log_bin globally is only detected when a new session is started. Any sessions previously running are not impacted when settingsql_log_bin globally.

Warning

Incorrect use of sql_log_bin with a global scope means any changes made in an already running session are stillbeing recorded to the binary log and therefore replicated. Exercise extreme caution using sql_log_bin with a global scope as the above situation could cause unexpected results including replication failure.

Beginning with MySQL 5.5.5, it is no longer possible to set @@session.sql_log_bin within a transaction or subquery. (Bug #53437)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值