Q:

MySQL supports running multiple mysqld on the same server. One of the ways is to use mysqld_multi.

If the default MySQL server instance (as configured in the [mysqld] section in my.cnf) uses log-bin, it enables the binary log for all the other instances ([mysqld1][mysqld2], etc). How can we override the setting for the other instances? We tried putting log-bin= or log-bin=OFF under[mysqld1], but that won't disable the binary log.

A:

You may have to resort to using this:

SET SQL_LOG_BIN=0;

/*
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 the SUPER privilege to set this variable. Beginning with MySQL 5.5.5, it is no longer possible to set @@session.sql_log_bin within a transaction or subquery. (Bug #53437)
*/

Run this each time you connect to mysql, and all queries you run during this session will not be recorded in the binary logs.

You could run the following command once in any instance of mysql in mysqld1 and disable binary logging for all connections thereafter until the next time mysqld1 is restarted:

SET SQL_LOG_BIN=0;
SET GLOBAL SQL_LOG_BIN=0;

This DOES NOT disable binary loggging. It just bypasses recording DDL, INSERTs, UPDATEs, and DELETEs. At least, you get to perform queries faster because of not having to record them.

I actually tried it out

lwdba@localhost (DB information_schema) :: show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 720 |
| mysql-bin.000002 | 4279 |
| mysql-bin.000003 | 128935976 |
+------------------+-----------+
3 rows in set (0.00 sec)

lwdba@localhost (DB information_schema) :: create database test8; show binary logs;
Query OK, 1 row affected (0.00 sec)

+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 720 |
| mysql-bin.000002 | 4279 |
| mysql-bin.000003 | 128936061 |
+------------------+-----------+
3 rows in set (0.00 sec)

lwdba@localhost (DB information_schema) :: set sql_log_bin=0; create table test8.dummy (a int) engine=MyISAM; insert into test8.dummy values (1),(2),(3); show binary logs;
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.06 sec)

Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 720 |
| mysql-bin.000002 | 4279 |
| mysql-bin.000003 | 128936061 |
+------------------+-----------+
3 rows in set (0.00 sec)

Notice how the create database command was recorded and the size of the last binary log changed. Then, notice how I disabled the binary log and created a table in the new test database, and added 3 rows to it. Yet, the last binary log stayed the same size.

Again, this will not disable binary logging for the instance, but this has to be the next best thing.

参考:

http://serverfault.com/questions/217783/how-to-turn-off-the-binary-log-for-mysqld-multi-instances

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

How to turn off the binary log for mysqld_multi instances?的更多相关文章

  1. [MySQL复制异常]'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.'

    MySQL复制错误]Last_Errno: 1666 Last_Error: Error executing row event: 'Cannot execute statement: imposs ...

  2. MySQL5.7基于binary log的主从复制

    MySQL5.7基于binary log的主从复制 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 基于binary log 的复制是指主库将修改操作写入binary log 中, ...

  3. 【转】[MySQL复制异常]Cannot execute statement: impossible to write to binary log since statement is in row for

    MySQL复制错误]Last_Errno: 1666 Last_Error: Error executing row event: 'Cannot execute statement: imposs ...

  4. mysql二进制文件操作语法(mysql binary log operate statements)

    开启 binary logs 功能 在 mysql 配置文件中配置 log-bin,重启 mysql my.cnf (on Linux/unix) or my.ini (on Windows) 例子: ...

  5. Concurrent inserts on MyISAM and the binary log

    Recently I had an interesting surprise with concurrent inserts into a MyISAM table. The inserts were ...

  6. 【MySQL】MySQL同步报错-> Last_IO_Error: Got fatal error 1236 from master when reading data from binary log

    这个报错网上搜索了一下,大部分是由于MySQL意外关闭或强制重启造成的binlog文件事务点读取异常造成的主从同步报错 Last_IO_Error: Got fatal error 1236 from ...

  7. mysql 主从 Got fatal error 1236 from master when reading data from binary log: 'Could not find first 错误

    本地MySQL环境,是两台MySQL做M-M复制.今天发现错误信息: mysql 5.5.28-log> show slave status\G ************************ ...

  8. 17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 得到复制master binary log 位置:

    17.1.1.4 Obtaining the Replication Master Binary Log Coordinates 得到复制master binary log 位置: 你需要master ...

  9. 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log 使用binay log 基于时间点恢复

    7.5 Point-in-Time (Incremental) Recovery Using the Binary Log 使用binay log 基于时间点恢复 7.5.1 Point-in-Tim ...

随机推荐

  1. python的爬虫代理设置

    现在网站大部分都是反爬虫技术,最简单就是加代理,写了一个代理小程序. # -*- coding: utf-8 -*- #__author__ = "雨轩恋i" #__date__ ...

  2. Leecode刷题之旅-C语言/python-28.实现strstr()

    /* * @lc app=leetcode.cn id=28 lang=c * * [28] 实现strStr() * * https://leetcode-cn.com/problems/imple ...

  3. PHP.37-TP框架商城应用实例-后台13-商品管理-扩展分类的添加、显示【数据分组】、搜索分类【多对多】

    商品扩展分类 需求:一件商品能有多个扩展分类,搜索任何一个分类都能搜出该商品 建表[扩展分类表] drop table if exists p39_goods_cat; create table p3 ...

  4. Ubuntu server中 samba的安装和简单配置

    samba是Linux系统上的一种文件共享协议,可以实现Windows系统访问Linux系统上的共享资源,现在介绍一下如何在Ubuntu 14.04上安装和配置samba 工具/原料   Ubuntu ...

  5. ArrayMap java.lang.ArrayIndexOutOfBoundsException

    错误堆栈: java.lang.ArrayIndexOutOfBoundsException: length=0; index=1 at android.support.v4.util.SimpleA ...

  6. JS控制文本框输入的内容

    总而言之:   先在‘<input>’ 里输入      onkeyup="value=value.replace(/[^\X]/g,'')" 然后在(/[\X]/g, ...

  7. 复制MySQL数据库A到另外一个MySQL数据库B(仅仅针对innodb数据库引擎)

    方案一:(不用太大的变化my.ini文件) copy 原数据库A中的   数据库(database)  ib_logfile1  ib_logfile0   ibdata1: 关闭目的数据库B: 备份 ...

  8. Scala学习笔记(三):基础知识

    有了可运行的环境,就需要写一些简单的语句来认识一下Scala,本文没有写那么详细,只是为了方便查看.唤起回忆 (1)变量的定义方法 Scala有两种变量 var val 注意:在解释器中,可以用一个之 ...

  9. jmeter多用户登录跨线程组操作传值

    项目需求: 需要登录两个用户A.B,用户A操作完后会通知B,然后B再操作,B操作完结束或者再通知A. 实现思路: 1. 设置两个线程组Ⅰ.Ⅱ,组Ⅰ添加cookie管理器,里面添加用户A的操作:组Ⅱ添加 ...

  10. 「暑期训练」「基础DP」 Monkey and Banana (HDU-1069)

    题意与分析 给定立方体(个数不限),求最多能堆叠(堆叠要求上方的方块严格小于下方方块)的高度. 表面上个数不限,问题是堆叠的要求决定了每个方块最多可以使用三次.然后就是对3n" role=& ...