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. 【Java】关于Spring MVC框架的总结

    SpringMVC是一种基于Java,实现了Web MVC设计模式,请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将Web层进行职责解耦.基于请求驱动指的就是使用请求-响应模型,框架的 ...

  2. 8 TFTP代码详解 协议写在程序中

    1.版本1:发送请求 # -*- coding:utf-8 -*- import struct from socket import * #0. 获取要下载的文件名字: downloadFileNam ...

  3. easyui 验证动态添加和删除问题

    $.extend($.fn.validatebox.methods, { remove: function(jq, newposition){ return jq.each(function(){ $ ...

  4. ReentrantLock类的hasQueuedPredecessors方法和head节点的含义

    部分启发来源自文章:Java并发编程--Lock PART 1 1.如果h==t成立,h和t均为null或是同一个具体的节点,无后继节点,返回false.2.如果h!=t成立,head.next是否为 ...

  5. ip4addr_ntoa和不可重入函数

    在网络中,有一个转换IP地址到ASIIC字符串的函数,该函数的返回值所指向的ASIIC字符串驻留在静态内存中,所以该函数不可重入. 通俗的讲,在多任务系统中,一个任务执行在调用运行这个函数的时候,其他 ...

  6. performance_schema实现套路

      实现中大量使用多层次嵌套预编译,大量if else,wrapper等 不建议去看这个实现 start_mutex_wait_v1 if (flag_thread_instrumentation) ...

  7. Fiddler安卓抓包详细教程

    电脑端抓包一般图方便就用浏览器自带的,最近需要分析安卓一个APP的HTTP请求,尝试了wireshark(功能太强大了,然而我并不会用),tcpdump(用起来还是比较麻烦),网上搜了一下,还是使用F ...

  8. 今天买了个pro,开始ios开发

    今天买了个mac pro 开始ios开发啦,爽!

  9. session、token、cookie的区别

    token就是令牌,比如你授权(登录)一个程序时,他就是个依据,判断你是否已经授权该软件cookie就是写在客户端的一个txt文件,里面包括你登录信息之类的,这样你下次在登录某个网站,就会自动调用co ...

  10. 第三篇 Postman之 Tests(后置处理器,断言)

    第二篇里讲了手动设置全局变量及局部变量的方法,但是这有一个缺点,就是每次测试之前,都需要获取相关变量值,手动再填写更新到对应的全局变量或者局部变量里,这对于想进行自动化执行的人或者懒人就不太友好了,本 ...