linux下mysql5.7.19数据库备份(增量备份恢复)

linux下mysql5.7.19数据库备份(增量备份恢复)

1.查看备份文件

mysqlbinlog  /var/lib/mysql/mysql-bin.000002 > /var/lib/mysql/tmp.sql

查看转换后的sql文件内容:

cat /var/lib/msql/tmp.sql

linux下mysql5.7.19数据库备份(增量备份恢复)_第1张图片

tmp.sql文件内容,如下:

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#170830  0:00:01 server id 1  end_log_pos 123 CRC32 0x42351239  Start: binlog v 4, server v 5.7.19-log created 170830  0:00:01
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
gY+lWQ8BAAAAdwAAAHsAAAABAAQANS43LjE5LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
ATkSNUI=
'/*!*/;
# at 123
#170830  0:00:01 server id 1  end_log_pos 154 CRC32 0x1645578e  Previous-GTIDs
# [empty]
# at 154
#170830 15:03:55 server id 1  end_log_pos 219 CRC32 0x1b689222  Anonymous_GTID  last_committed=0    sequence_number=1   rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
# at 219
#170830 15:03:55 server id 1  end_log_pos 294 CRC32 0x83ddff05  Query   thread_id=73    exec_time=0 error_code=0
SET TIMESTAMP=1504076635/*!*/;
SET @@session.pseudo_thread_id=73/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1436549152/*!*/;
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/*!*/;
BEGIN
/*!*/;
# at 294
#170830 15:03:55 server id 1  end_log_pos 351 CRC32 0x257dafb4  Table_map: `szsjrjg`.`a_Test` mapped to number 219
# at 351
#170830 15:03:55 server id 1  end_log_pos 392 CRC32 0xa9297bb8  Write_rows: table id 219 flags: STMT_END_F

BINLOG '
W2OmWRMBAAAAOQAAAF8BAAAAANsAAAAAAAEAB3N6c2pyamcABmFfVGVzdAACDw8EKAAoAAC0r30l
W2OmWR4BAAAAKQAAAIgBAAAAANsAAAAAAAEAAgAC//wBNwI3N7h7Kak=
'/*!*/;
# at 392
#170830 15:03:55 server id 1  end_log_pos 423 CRC32 0x5aa60d51  Xid = 153
COMMIT/*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

2.还原数据的基本语句

linux系统下,还原mysql-bin.000001到数据库test_database

mysqlbinlog /var/lib/mysql/mysql-bin.000001 | mysql -uroot -p --one-database test_database

你可能感兴趣的:(mysql,数据库,备份,mysql,linux)