load data方式导入的数据不可以用binlog日志进行恢复,因为binlo_MySQL
bitsCN.com
load data方式导入的数据不可以用binlog日志进行恢复,因为binlog里面不产生insert sql语句
QQ群里面有人问起这个问题: 用load data 导入数据的时候,在binlog文件中记录的不是insert 语句,这样的话,如果用load data 导入数据,当需要恢复数据库的时候 binlog恢复就不行了
load data local infile '/root/table.txt' into table test.table ;
生成binlog 日志
然后用mysqlbinlog解析binlog日志,再more查看如下:
# at 147405
#130718 3:15:02 server id 1 end_log_pos 147710 Query thread_id=97960 exec_time=0 error_code=0
use test/*!*/;
SET TIMESTAMP=1374117302/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!/C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
create table `test`.`table`(
`c1` varchar(20) ,
`c2` varchar(20) ,
`c3` varchar(20) ,
`c4` varchar(20) ,
`c5` varchar(20) ,
`c6` varchar(20) ,
`c7` varchar(20) ,
`c8` varchar(20) ,
`c9` varchar(20)
)
/*!*/;
# at 147710
#130718 3:17:14 server id 1 end_log_pos 147783 Query thread_id=98119 exec_time=2 error_code=0
SET TIMESTAMP=1374117434/*!*/;
SET @@session.sql_mode=4194304/*!*/;
BEGIN
/*!*/;
# at 147783
#130718 3:17:14 server id 1 end_log_pos 164190
#Begin_load_query: file_id: 1 block_len: 16384
# at 164190
#130718 3:17:14 server id 1 end_log_pos 180597
#Append_block: file_id: 1 block_len: 16384
# at 180597
#130718 3:17:14 server id 1 end_log_pos 197004
#Append_block: file_id: 1 block_len: 16384
# at 197004
#130718 3:17:14 server id 1 end_log_pos 213411
#Append_block: file_id: 1 block_len: 16384
# at 213411
#130718 3:17:14 server id 1 end_log_pos 229818
#Append_block: file_id: 1 block_len: 16384
# at 229818
#130718 3:17:14 server id 1 end_log_pos 246225
#Append_block: file_id: 1 block_len: 16384
# at 246225
#130718 3:17:14 server id 1 end_log_pos 262632
#Append_block: file_id: 1 block_len: 16384
# at 262632
#130718 3:17:14 server id 1 end_log_pos 279039
#Append_block: file_id: 1 block_len: 16384
# at 279039
#130718 3:17:14 server id 1 end_log_pos 295446
#Append_block: file_id: 1 block_len: 16384
# at 295446
#130718 3:17:14 server id 1 end_log_pos 311853
#Append_block: file_id: 1 block_len: 16384
# at 311853
#130718 3:17:14 server id 1 end_log_pos 328260
#Append_block: file_id: 1 block_len: 16384
# at 328260
#130718 3:17:14 server id 1 end_log_pos 344667
#Append_block: file_id: 1 block_len: 16384
# at 344667
#130718 3:17:14 server id 1 end_log_pos 361074
#Append_block: file_id: 1 block_len: 16384
# at 361074
#130718 3:17:14 server id 1 end_log_pos 377481
#Append_block: file_id: 1 block_len: 16384
# at 377481
#130718 3:17:14 server id 1 end_log_pos 393888
#Append_block: file_id: 1 block_len: 16384
# at 393888
#130718 3:17:14 server id 1 end_log_pos 410295
#Append_block: file_id: 1 block_len: 16384
# at 410295
#130718 3:17:14 server id 1 end_log_pos 426702
#Append_block: file_id: 1 block_len: 16384
# at 426702
#130718 3:17:14 server id 1 end_log_pos 443109
#Append_block: file_id: 1 block_len: 16384
# at 443109
#130718 3:17:14 server id 1 end_log_pos 459516
#Append_block: file_id: 1 block_len: 16384
# at 459516
#130718 3:17:14 server id 1 end_log_pos 475923
#Append_block: file_id: 1 block_len: 16384
# at 475923
#130718 3:17:14 server id 1 end_log_pos 492330
#Append_block: file_id: 1 block_len: 16384
# at 492330
#130718 3:17:14 server id 1 end_log_pos 508737
#Append_block: file_id: 1 block_len: 16384
# at 508737
#130718 3:17:14 server id 1 end_log_pos 525144
#Append_block: file_id: 1 block_len: 16384
# at 525144
#130718 3:17:14 server id 1 end_log_pos 541551
#Append_block: file_id: 1 block_len: 16384
# at 541551
#130718 3:17:14 server id 1 end_log_pos 557958
#Append_block: file_id: 1 block_len: 16384
# at 557958
#130718 3:17:14 server id 1 end_log_pos 574365
#Append_block: file_id: 1 block_len: 16384
# at 574365
#130718 3:17:14 server id 1 end_log_pos 590772
#Append_block: file_id: 1 block_len: 16384
# at 590772
#130718 3:17:14 server id 1 end_log_pos 607179
#Append_block: file_id: 1 block_len: 16384
# at 607179
#130718 3:17:14 server id 1 end_log_pos 623586
#Append_block: file_id: 1 block_len: 16384
# at 623586
#130718 3:17:14 server id 1 end_log_pos 639993
#Append_block: file_id: 1 block_len: 16384
# at 639993
#130718 3:17:14 server id 1 end_log_pos 656400
#Append_block: file_id: 1 block_len: 16384
# at 656400
#130718 3:17:14 server id 1 end_log_pos 672807
#Append_block: file_id: 1 block_len: 16384
# at 672807
#130718 3:17:14 server id 1 end_log_pos 689214
#Append_block: file_id: 1 block_len: 16384
# at 689214
#130718 3:17:14 server id 1 end_log_pos 705621
#Append_block: file_id: 1 block_len: 16384
# at 705621
#130718 3:17:14 server id 1 end_log_pos 722028
#Append_block: file_id: 1 block_len: 16384
# at 722028
#130718 3:17:14 server id 1 end_log_pos 738435
#Append_block: file_id: 1 block_len: 16384
# at 738435
#130718 3:17:14 server id 1 end_log_pos 754842
#Append_block: file_id: 1 block_len: 16384
# at 754842
#130718 3:17:14 server id 1 end_log_pos 771249
#Append_block: file_id: 1 block_len: 16384
# at 771249
#130718 3:17:14 server id 1 end_log_pos 787656
#Append_block: file_id: 1 block_len: 16384
# at 787656
#130718 3:17:14 server id 1 end_log_pos 804063
#Append_block: file_id: 1 block_len: 16384
# at 804063
#130718 3:17:14 server id 1 end_log_pos 820470
#Append_block: file_id: 1 block_len: 16384
# at 820470
#130718 3:17:14 server id 1 end_log_pos 836877
#Append_block: file_id: 1 block_len: 16384
# at 836877
#130718 3:17:14 server id 1 end_log_pos 853284
#Append_block: file_id: 1 block_len: 16384
# at 853284
#130718 3:17:14 server id 1 end_log_pos 869691
#Append_block: file_id: 1 block_len: 16384
# at 869691
#130718 3:17:14 server id 1 end_log_pos 886098
#Append_block: file_id: 1 block_len: 16384
# at 886098
#130718 3:17:14 server id 1 end_log_pos 902505
#Append_block: file_id: 1 block_len: 16384
# at 902505
#130718 3:17:14 server id 1 end_log_pos 918912
#Append_block: file_id: 1 block_len: 16384
# at 918912
#130718 3:17:14 server id 1 end_log_pos 935319
#Append_block: file_id: 1 block_len: 16384
# at 935319
#130718 3:17:14 server id 1 end_log_pos 951726
#Append_block: file_id: 1 block_len: 16384
# at 951726
#130718 3:17:14 server id 1 end_log_pos 968133
#Append_block: file_id: 1 block_len: 16384
# at 968133
#130718 3:17:14 server id 1 end_log_pos 984540
#Append_block: file_id: 1 block_len: 16384
# at 984540
#130718 3:17:14 server id 1 end_log_pos 1000947
#Append_block: file_id: 1 block_len: 16384
# at 1000947
#130718 3:17:14 server id 1 end_log_pos 1017354
#Append_block: file_id: 1 block_len: 16384
# at 1017354
#130718 3:17:14 server id 1 end_log_pos 1033761
#Append_block: file_id: 1 block_len: 16384
# at 1033761
#130718 3:17:14 server id 1 end_log_pos 1050168
#Append_block: file_id: 1 block_len: 16384
# at 1050168
#130718 3:17:14 server id 1 end_log_pos 1066575
#Append_block: file_id: 1 block_len: 16384
# at 1066575
#130718 3:17:14 server id 1 end_log_pos 1082982
#Append_block: file_id: 1 block_len: 16384
# at 1082982
#130718 3:17:14 server id 1 end_log_pos 1099389
#Append_block: file_id: 1 block_len: 16384
# at 1099389
#130718 3:17:14 server id 1 end_log_pos 1115796
#Append_block: file_id: 1 block_len: 16384
# at 1115796
#130718 3:17:14 server id 1 end_log_pos 1132203
#Append_block: file_id: 1 block_len: 16384
# at 1132203
#130718 3:17:14 server id 1 end_log_pos 1148610
#Append_block: file_id: 1 block_len: 16384
# at 1148610
#130718 3:17:14 server id 1 end_log_pos 1165017
#Append_block: file_id: 1 block_len: 16384
# at 1165017
#130718 3:17:14 server id 1 end_log_pos 1181424
#Append_block: file_id: 1 block_len: 16384
# at 1181424
#130718 3:17:14 server id 1 end_log_pos 1197831
#Append_block: file_id: 1 block_len: 16384
# at 1197831
#130718 3:17:14 server id 1 end_log_pos 1214238
#Append_block: file_id: 1 block_len: 16384
# at 1214238
#130718 3:17:14 server id 1 end_log_pos 1230645
#Append_block: file_id: 1 block_len: 16384
# at 1230645
#130718 3:17:14 server id 1 end_log_pos 1247052
#Append_block: file_id: 1 block_len: 16384
# at 1247052
#130718 3:17:14 server id 1 end_log_pos 1263459
#Append_block: file_id: 1 block_len: 16384
# at 1263459
#130718 3:17:14 server id 1 end_log_pos 1279866
#Append_block: file_id: 1 block_len: 16384
# at 1279866
#130718 3:17:14 server id 1 end_log_pos 1296273
#Append_block: file_id: 1 block_len: 16384
# at 1296273
#130718 3:17:14 server id 1 end_log_pos 1312680
#Append_block: file_id: 1 block_len: 16384
# at 1312680
#130718 3:17:14 server id 1 end_log_pos 1329087
#Append_block: file_id: 1 block_len: 16384
# at 1329087
#130718 3:17:14 server id 1 end_log_pos 1345494
.........
#Append_block: file_id: 1 block_len: 16384
# at 4298754
#130718 3:17:14 server id 1 end_log_pos 4315161
#Append_block: file_id: 1 block_len: 16384
# at 4315161
#130718 3:17:14 server id 1 end_log_pos 4331568
#Append_block: file_id: 1 block_len: 16384
# at 4331568
#130718 3:17:14 server id 1 end_log_pos 4347975
#Append_block: file_id: 1 block_len: 16384
# at 4347975
#130718 3:17:14 server id 1 end_log_pos 4364382
#Append_block: file_id: 1 block_len: 16384
# at 4364382
#130718 3:17:14 server id 1 end_log_pos 4380789
#Append_block: file_id: 1 block_len: 16384
# at 4380789
#130718 3:17:14 server id 1 end_log_pos 4397196
#Append_block: file_id: 1 block_len: 16384
# at 4397196
#130718 3:17:14 server id 1 end_log_pos 4413603
#Append_block: file_id: 1 block_len: 16384
# at 4413603
#130718 3:17:14 server id 1 end_log_pos 4430010
#Append_block: file_id: 1 block_len: 16384
# at 4430010
#130718 3:17:14 server id 1 end_log_pos 4446417
#Append_block: file_id: 1 block_len: 16384
# at 4446417
#130718 3:17:14 server id 1 end_log_pos 4462824
#Append_block: file_id: 1 block_len: 16384
# at 4462824
#130718 3:17:14 server id 1 end_log_pos 4479231
#Append_block: file_id: 1 block_len: 16384
# at 4479231
#130718 3:17:14 server id 1 end_log_pos 4495638
#Append_block: file_id: 1 block_len: 16384
# at 4495638
#130718 3:17:14 server id 1 end_log_pos 4512045
#Append_block: file_id: 1 block_len: 16384
# at 4512045
#130718 3:17:14 server id 1 end_log_pos 4528452
#Append_block: file_id: 1 block_len: 16384
# at 4528452
#130718 3:17:14 server id 1 end_log_pos 4544859
#Append_block: file_id: 1 block_len: 16384
# at 4544859
#130718 3:17:14 server id 1 end_log_pos 4561266
#Append_block: file_id: 1 block_len: 16384
# at 4561266
#130718 3:17:14 server id 1 end_log_pos 4577673
#Append_block: file_id: 1 block_len: 16384
# at 4577673
#130718 3:17:14 server id 1 end_log_pos 4594080
#Append_block: file_id: 1 block_len: 16384
# at 4594080
#130718 3:17:14 server id 1 end_log_pos 4610487
#Append_block: file_id: 1 block_len: 16384
# at 4610487
#130718 3:17:14 server id 1 end_log_pos 4626894
#Append_block: file_id: 1 block_len: 16384
# at 4626894
#130718 3:17:14 server id 1 end_log_pos 4643301
#Append_block: file_id: 1 block_len: 16384
# at 4643301
#130718 3:17:14 server id 1 end_log_pos 4659708
#Append_block: file_id: 1 block_len: 16384
# at 4659708
#130718 3:17:14 server id 1 end_log_pos 4676115
#Append_block: file_id: 1 block_len: 16384
# at 4676115
#130718 3:17:14 server id 1 end_log_pos 4692522
#Append_block: file_id: 1 block_len: 16384
# at 4692522
#130718 3:17:14 server id 1 end_log_pos 4708929
#Append_block: file_id: 1 block_len: 16384
# at 4708929
#130718 3:17:14 server id 1 end_log_pos 4725336
#Append_block: file_id: 1 block_len: 16384
# at 4725336
#130718 3:17:14 server id 1 end_log_pos 4735417
#Append_block: file_id: 1 block_len: 10058
# at 4735417
#130718 3:17:14 server id 1 end_log_pos 4735701 Execute_load_query thread_id=98119 exec_time=2 error_code=0
SET TIMESTAMP=1374117434/*!*/;
LOAD DATA LOCAL INFILE '/tmp/SQL_LOAD_MB-1-0' INTO TABLE `table` FIELDS TERMINATED BY '/t' ENCLOSED BY '' ESCAPED BY '//' LINES TERMINATED BY '/n' (`c1`, `c2`, `c3`, `
c4`, `c5`, `c6`, `c7`, `c8`, `c9`)
/*!*/;
# file_id: 1
# at 4735701
#130718 3:17:14 server id 1 end_log_pos 4735728 Xid = 297745
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
确实没有insert之类的sql语句,当用binlog日志进行恢复的时候,会报错的,所以在生产环境上面,最好不要使用load data的方式进行数据导入。以免需要及时恢复数据的时候发生异常。
-- 察看binlog事件,会看到最后的load data local infile纪录.
[sql] view plaincopyprint?
mysql> show binlog events in "mysql-bin.000001";
......
| mysql-bin.000001 | 4708929 | Append_block | 1 | 4725336 | ;file_id=1;block_len=16384 |
| mysql-bin.000001 | 4725336 | Append_block | 1 | 4735417 | ;file_id=1;block_len=10058 |
| mysql-bin.000001 | 4735417 | Execute_load_query | 1 | 4735701 | use `test`; LOAD DATA LOCAL INFILE '/root/table.txt' IGNORE INTO TABLE `table` FIELDS TERMINATED BY '/t' ENCLOSED BY '' ESCAPED BY '//' LINES TERMINATED BY '/n' (`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`, `c9`) ;file_id=1 |
| mysql-bin.000001 | 4735701 | Xid | 1 | 4735728 | COMMIT /* xid=297745 */
-- 再察看从库数据也都同步复制过去了,再看从库的binlog日志
# at 31990800
#130718 11:15:02 server id 1 end_log_pos 31991105 Query thread_id=97960 exec_time=4294967292 error_code=0
use test/*!*/;
SET TIMESTAMP=1374117302/*!*/;
SET @@session.sql_mode=0/*!*/;
/*!/C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
create table `test`.`table`(
`c1` varchar(20) ,
`c2` varchar(20) ,
`c3` varchar(20) ,
`c4` varchar(20) ,
`c5` varchar(20) ,
`c6` varchar(20) ,
`c7` varchar(20) ,
`c8` varchar(20) ,
`c9` varchar(20)
)
/*!*/;
# at 31991105
#130718 11:17:14 server id 1 end_log_pos 31991169 Query thread_id=98119 exec_time=4 error_code=0
SET TIMESTAMP=1374117434/*!*/;
SET @@session.sql_mode=4194304/*!*/;
BEGIN
/*!*/;
# at 31991169
#130718 11:17:14 server id 1 end_log_pos 34088344
#Begin_load_query: file_id: 1 block_len: 2097152
# at 34088344
#130718 11:17:14 server id 1 end_log_pos 36185519
#Append_block: file_id: 1 block_len: 2097152
# at 36185519
#130718 11:17:14 server id 1 end_log_pos 36572432
#Append_block: file_id: 1 block_len: 386890
# at 36572432
#130718 11:17:14 server id 1 end_log_pos 36572723 Execute_load_query thread_id=98119 exec_time=4 error_code=0
SET TIMESTAMP=1374117434/*!*/;
LOAD DATA LOCAL INFILE '/tmp/SQL_LOAD_MB-1-0' INTO TABLE `table` FIELDS TERMINATED BY '/t' ENCLOSED BY '' ESCAPED BY '//' LINES TERMINATED BY '/n' (`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`, `c9`)
/*!*/;
# file_id: 1
# at 36572723
#130718 11:17:14 server id 1 end_log_pos 36572750 Xid = 839475877
COMMIT/*!*/;
-- 再去主库从库上面的tmp目录察看临时文件存在情况,果然看到SQL_LOAD_MB-1-0文件存在.
[root@eanshlt2mydbc001db002 tmp]# ll -t /tmp/ |more
total 2212772
-rw-r----- 1 root root 4581194 Jul 18 11:46 SQL_LOAD_MB-1-0
bitsCN.com
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

How to View Command History in Linux In Linux, we use the history command to view the list of all previously executed commands. It has a very simple syntax: history Some options for pairing with the history command include: Option description -c clears the command history for the current session -w writes the command history to a file -r reloads the command history from the history file -n Limit the number of output of recent commands Simply run the history command to see a list of all previously executed commands in a Linux terminal: In addition to viewing command history, you can also manage command history and perform modifications to previously executed commands , reverse search command history or even delete history completely

Call recording in iPhone is often underestimated and is one of the most critical features of iPhone. With its simplicity, this feature is of vital importance and can provide important insights about the calls made or received on the device. Whether for work purposes or legal proceedings, the ability to access call records can prove invaluable. In simple terms, call history refers to the entries created on your iPhone whenever you make or receive a call. These logs contain key information, including the contact's name (or number if not saved as a contact), timestamp, duration, and call status (dialed, missed, or not answered). They are a concise record of your communication history. Call history includes call history strips stored on your iPhone

iPhone lets you add medications to the Health app to track and manage the medications, vitamins and supplements you take every day. You can then log medications you've taken or skipped when you receive a notification on your device. After you log your medications, you can see how often you took or skipped them to help you track your health. In this post, we will guide you to view the log history of selected medications in the Health app on iPhone. A short guide on how to view your medication log history in the Health App: Go to the Health App>Browse>Medications>Medications>Select a Medication>Options&a

C# Development Suggestions: Logging and Monitoring System Summary: In the software development process, logging and monitoring systems are crucial tools. This article will introduce the role and implementation suggestions of logging and monitoring systems in C# development. Introduction: Logging and monitoring are essential tools in large-scale software development projects. They can help us understand the running status of the program in real time and quickly discover and solve problems. This article will discuss how to use logging and monitoring systems in C# development to improve software quality and development efficiency. The role of logging system

The difference between insertignore, insert and replace instructions already exist or not. Example of insert error. Insertintonames(name,age)values("Xiao Ming", 23); insertignore ignores insertignoreintonames(name, age)values("Xiao Ming", 24); replace Replace and insert replaceintonames(name,age)values("Xiao Ming", 25); table requirements: PrimaryKey, or unique index result: the table id will be automatically incremented. Test code creates table

How to log and monitor Java development projects 1. Background introduction With the rapid development of the Internet, more and more companies have begun to develop Java and build various types of applications. In the development process, logging and monitoring are an important link that cannot be ignored. Through logging and monitoring, developers can discover and solve problems in time to ensure the stability and security of applications. 2. The importance of logging 1. Problem tracking: When an application error occurs, logging can help us quickly locate the problem.

Use java's StringBuilder.insert() function to insert a string at a specified position. StringBuilder is a class in Java used to handle variable strings. It provides a variety of methods to operate strings. The insert() function is used to insert strings at specified positions. One of the common methods of positionally inserting strings. In this article, we will introduce how to use the insert() function to insert a string at a specified position and give corresponding code examples. insert()
