MySQL禁用binlog中的语句

php中文网
发布: 2016-06-07 17:34:58
原创
1152人浏览过

MySQL复制是异步的,也就是说是非同步的过程,它不会校验数据库中数据的一致性,只要SQL语法正确并且没有错误就能成功执行

mysql复制是异步的,也就是说是非同步的过程,它不会校验数据库中数据的一致性,只要sql语法正确并且没有错误就能成功执行

[plain] view plaincopyprint?
MASTER@root@test 12:20:40>create table tab01 
    -> (id int(10) primary key , 
    -> name varchar(20)); 
Query OK, 0 rows affected (0.03 sec) 
 
MASTER@root@test 12:21:32> 
MASTER@root@test 12:21:49>show master status; 
+----------------------+----------+--------------+------------------+ 
| File                | Position | Binlog_Do_DB | Binlog_Ignore_DB | 
+----------------------+----------+--------------+------------------+ 
| binlog-master.000004 |      338 |              |                  | 
+----------------------+----------+--------------+------------------+ 
1 row in set (0.00 sec) 
 
MASTER@root@test 12:21:52> 

MASTER@root@test 12:20:40>create table tab01
    -> (id int(10) primary key ,
    -> name varchar(20));
Query OK, 0 rows affected (0.03 sec)

MASTER@root@test 12:21:32>
MASTER@root@test 12:21:49>show master status;
+----------------------+----------+--------------+------------------+
| File                | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+----------------------+----------+--------------+------------------+
| binlog-master.000004 |      338 |              |                  |
+----------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

MASTER@root@test 12:21:52>[plain] view plaincopyprint?
[root@mynode1 mysql]# /service/mysql/bin/mysqlbinlog binlog-master.000004|tail -13 
# at 213 
#140130 12:21:32 server id 1  end_log_pos 338  Query  thread_id=3    exec_time=0    error_code=0 
use `test`/*!*/; 
SET TIMESTAMP=1391055692/*!*/; 
create table tab01 
(id int(10) primary key , 
name varchar(20)) 
/*!*/; 
DELIMITER ; 
# End of log file 
ROLLBACK /* added by mysqlbinlog */; 
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 

[root@mynode1 mysql]# /service/mysql/bin/mysqlbinlog binlog-master.000004|tail -13
# at 213
#140130 12:21:32 server id 1  end_log_pos 338  Query  thread_id=3    exec_time=0    error_code=0
use `test`/*!*/;
SET TIMESTAMP=1391055692/*!*/;
create table tab01
(id int(10) primary key ,
name varchar(20))
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

 

启科网络PHP商城系统
启科网络PHP商城系统

启科网络商城系统由启科网络技术开发团队完全自主开发,使用国内最流行高效的PHP程序语言,并用小巧的MySql作为数据库服务器,并且使用Smarty引擎来分离网站程序与前端设计代码,让建立的网站可以自由制作个性化的页面。 系统使用标签作为数据调用格式,网站前台开发人员只要简单学习系统标签功能和使用方法,将标签设置在制作的HTML模板中进行对网站数据、内容、信息等的调用,即可建设出美观、个性的网站。

启科网络PHP商城系统 0
查看详情 启科网络PHP商城系统

可以看到binlog里记录了这条语句,可以通过sql_log_bin参数来控制是否捕获binlog中的操作

[plain] view plaincopyprint?
MASTER@root@test 12:25:32>set sql_log_bin=0; 
Query OK, 0 rows affected (0.00 sec) 
 
MASTER@root@test 12:25:37>alter table tab01 add index(name); 
Query OK, 0 rows affected (0.05 sec) 
Records: 0  Duplicates: 0  Warnings: 0 
 
MASTER@root@test 12:26:04>set sql_log_bin=1; 
Query OK, 0 rows affected (0.00 sec) 
 
MASTER@root@test 12:26:07> 
MASTER@root@test 12:26:08>show create table tab01\G 
*************************** 1. row *************************** 
      Table: tab01 
Create Table: CREATE TABLE `tab01` ( 
  `id` int(10) NOT NULL, 
  `name` varchar(20) DEFAULT NULL, 
  PRIMARY KEY (`id`), 
  KEY `name` (`name`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 
1 row in set (0.00 sec) 

MASTER@root@test 12:25:32>set sql_log_bin=0;
Query OK, 0 rows affected (0.00 sec)

MASTER@root@test 12:25:37>alter table tab01 add index(name);
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

MASTER@root@test 12:26:04>set sql_log_bin=1;
Query OK, 0 rows affected (0.00 sec)

MASTER@root@test 12:26:07>
MASTER@root@test 12:26:08>show create table tab01\G
*************************** 1. row ***************************
      Table: tab01
Create Table: CREATE TABLE `tab01` (
  `id` int(10) NOT NULL,
  `name` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
[plain] view plaincopyprint?
[root@mynode1 mysql]# /service/mysql/bin/mysqlbinlog binlog-master.000004 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 
/*!40019 SET @@session.max_insert_delayed_threads=0*/; 
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 
DELIMITER /*!*/; 
# at 4 
#140130 12:08:05 server id 1  end_log_pos 107  Start: binlog v 4, server v 5.5.34-log created 140130 12:08:05 at startup 
# Warning: this binlog is either in use or was not closed properly. 
ROLLBACK/*!*/; 
BINLOG ' 
JdDpUg8BAAAAZwAAAGsAAAABAAQANS41LjM0LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 
AAAAAAAAAAAAAAAAAAAl0OlSEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA== 
'/*!*/; 
# at 107 
#140130 12:13:45 server id 1  end_log_pos 213  Query  thread_id=3    exec_time=0    error_code=0 
use `tmp`/*!*/; 
SET TIMESTAMP=1391055225/*!*/; 
SET @@session.pseudo_thread_id=3/*!*/; 
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 
SET @@session.sql_mode=0/*!*/; 
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 
/*!\C utf8 *//*!*/; 
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/; 
SET @@session.lc_time_names=0/*!*/; 
SET @@session.collation_database=DEFAULT/*!*/; 
create table tab_02 as select * from tab_tmp 
/*!*/; 
# at 213 
#140130 12:21:32 server id 1  end_log_pos 338  Query  thread_id=3    exec_time=0    error_code=0 
use `test`/*!*/; 
SET TIMESTAMP=1391055692/*!*/; 
create table tab01 
(id int(10) primary key , 
name varchar(20)) 
/*!*/; 
DELIMITER ; 
# End of log file 
ROLLBACK /* added by mysqlbinlog */; 
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 
[root@mynode1 mysql]# 

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号