mysql>CREATETABLE`test`(`id`int(11)NOTNULLAUTO_INCREMENT,`price`int(10)DEFAULTNULL,PRIMARYKEY(`id`));
Query OK,0rows affected
mysql>desc test;+-------+---------+------+-----+---------+----------------+| Field |Type|Null|Key|Default| Extra |+-------+---------+------+-----+---------+----------------+| id |int(11)|NO| PRI |NULL|auto_increment|| price |int(10)| YES ||NULL||+-------+---------+------+-----+---------+----------------+2rowsinset
插入数据
mysql>insertinto test values(1,2),(2,3),(3,4);
Query OK,3rows affected
Records: 3 Duplicates: 0Warnings: 0
mysql>select*from test;+----+-------+| id | price |+----+-------+|1|2||2|3||3|4|+----+-------+3rowsinset
查看binlog记录
D:\mysql-5.6.36-winx64\data> mysqlbinlog mysql-bin.000001
// .....
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE `test`(`id` int(11) NOT NULL AUTO_INCREMENT,
`price` int(10) DEFAULT NULL,
PRIMARY KEY (`id`))
/*!*/;
SET TIMESTAMP=1545790350/*!*/;
BEGIN
/*!*/;
SET TIMESTAMP=1545790350/*!*/;
insert into test values(1,2),(2,3),(3,4)
/*!*/;
COMMIT/*!*/;
DELIMITER ;# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
删除表
# 暂停mysql的二进制日志功能
mysql>set SQL_LOG_BIN=0;
Query OK,0rows affected
mysql>droptable test;
Query OK,0rows affected
mysql>select*from test;1146-Table0000.test does not exist
恢复数据
mysql>set SQL_LOG_BIN=1;
Query OK,0rows affected
D:\mysql-5.6.36-winx64\data>mysqlbinlog mysql-bin.000001|mysql -uroot -p
Enter password: ****
mysql>select*from test;+----+-------+| id | price |+----+-------+|1|2||2|3||3|4|+----+-------+3rowsinset