当前位置:网站首页>MySQL restores data through binlog file

MySQL restores data through binlog file

2022-04-23 16:49:00 A coir boat in the broken white clouds

  1. take dump Unzip the compressed package to /data/dumpback/ Under the table of contents

    tar -zxvf back_20220322.tar.gz -C /databak/data
    
  2. Get into mysql perform

    # Sign in mysql
    mysql -uroot -p -S /data/mysql/mysql.sock
    
    # Select the target database 
    use zzz_test;
    
    # perform sql file ( The data recovery of scheduled backup is completed 
    source /data/dumpback/data/mysql/20220322/zzz_test.sql
    
  3. Use binlog The log will dump Data recovery after time

    # see binlog Log on Status (on To open )
    show variables like 'log_bin';
    
    # Inquire about  BINLOG  Format 
    show VARIABLES like 'binlog_format';
    
    # see  master  Writing  BINLOG  Information 
    show master status\G;
    
    # sign out mysql
    exit
    
    #cat /etc/my.cnf  Check the binary log storage directory 
    log_bin=/data/mysql/logs/mysql-bin
    
    #  see binlog file (mysql Restart once ,binlog The file name will change once 
    mysqlbinlog mysql-bin.000006
    
    # According to the time interval binlog Document conversion .sql The file to view 
    /usr/bin/mysqlbinlog --no-defaults --database=zzz_test --base64-output=decode-rows -v  --start-datetime='2022-03-25 09:39:10' --stop-datetime="2022-03-25 13:42:10" /var/lib/mysql/my-logbin.000069 >/databak/data/binlog.sql
    
     # Execute binaries according to time ( Restore the data content after the backup time 
    /usr/bin/mysqlbinlog --database=zzz_test --start-datetime='2022-03-25 13:53:29' --stop-datetime='2022-03-25 13:55:01' /var/lib/mysql/my-logbin.000069  | mysql -uroot -p123456
    

版权声明
本文为[A coir boat in the broken white clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400068213.html