Home Database Mysql Tutorial mysql复制中临时表的运用技巧_MySQL

mysql复制中临时表的运用技巧_MySQL

Jun 01, 2016 pm 01:23 PM
mysql Skill

bitsCN.com 我们知道,临时表有以下特性:
1. SESSION 级别,SESSION 一旦断掉,就被自动DROP 了。
2. 和默认引擎有关。如果默认引擎是INNODB,而你又疯狂的使用临时表。那么,你的IBDATA会被无限的增大。
3. 和磁盘表一样,默认写入到binlog, 而且被动的加入了rollback 计划。

幻想如下场景:
数据库损坏,也没有备份。刚好二进制日志全部保存完好,幸福了。导入二进制日志到MYSQL。

有两种方法:
1) mysqlbinlog ..... *.log | mysql dbname; 这种利用管道直接恢复数据,时间短,效率高。 可里面如果有一堆的临时表,而且刚好在日志的中间,那么悲剧了, 导入失败。 (回想临时表的特性就知道了。)
2) mysqlbinlog ..... *.log > result.log;mysql dbname
如果有大量的临时表应用, 那么在主从复制中,应该采取的正确方法为: (这个我可是08年就说过了。)
在写数据时,当然这里只的是主机。 无论在应用程序或者自己用客户端对MYSQL来进行管理,都应该这样:

[sql]
SET SQL_LOG_BIN=0;
关掉SESSION级别的复制。
update tmp_t1, tmp_t2 set ....;
drop tmp_t1;
drop tmp_t2;
SET SQL_LOG_BIN=1;

打开SESSION级别的复制。bitsCN.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

PHP's big data structure processing skills

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

How to use MySQL backup and restore in PHP?

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into a MySQL table using PHP?

What are the application scenarios of Java enumeration types in databases? What are the application scenarios of Java enumeration types in databases? May 05, 2024 am 09:06 AM

What are the application scenarios of Java enumeration types in databases?

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

How to use MySQL stored procedures in PHP?

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

How to create a MySQL table using PHP?

See all articles