Preparation Environment:
< Span style= "box-sizing:border-box;padding-right:0.1px" > two hosts:
a:192.168.1.6 data corruption
b:192.168.1.7 data recovery
Build steps:
Host A (192.168.1.6):
< Span style= "box-sizing:border-box;padding-right:0.1px" >mysqldump-a-F--single-transaction--master-data=1 >/ Backup/fullbak ' Date +%f '. SQL
labeled red Location is the latest generated new binaries and locations (all previous backups) after a full backup for binary log recovery
< Span style= "box-sizing:border-box;padding-right:0.1px" >mysql> create database db1;
mysql> CREATE database DB2;
< Span style= "box-sizing:border-box;padding-right:0.1px" ># rm-rf/var/lib/mysql/*
< Span style= "box-sizing:border-box;padding-right:0.1px" >systemctl stop mariadb
< Span style= "box-sizing:border-box;padding-right:0.1px" >mysqlbinlog--start-position=245 mariadb-bin.000002 >/ Backup/bin.sql
< Span style= "box-sizing:border-box;padding-right:0.1px" >scp/backup/fullbak2018-06-16.sql/backup/bin.sql 192.168.1.7:/root/
Host B (192.168.1.7):
< Span style= "box-sizing:border-box;padding-right:0.1px" >vim/etc/my.cnf
[mysqld]
Skip_networking
< Span style= "box-sizing:border-box;padding-right:0.1px" >systemctl start mariadb
< Span style= "box-sizing:border-box;padding-right:0.1px" >mysql </root/fullbak2018-06-16.sql Full backup recovery
mysql </root/bin.sql binary log recovery
How MySQL data file corruption is restored to its latest state