Binlog commands and restoration techniques in MySQL: show binlog events in 'MySQL-bin.000016 'limit 10;
Reset master deletes all binary logs
Flush logs generates a new binlog log file
Show master logs; or show binary logs; view the binary file list and file size
./Mysqlbinlog -- start-datetime = "2012-05-21 15:30:00" -- stop-datetime = "2012-05-21 16:40:00"/binlog/mysql-bin.000005> a. log
2. to restore the database through logs, you should have the following definition in your my. cnf File: log-bin = mysql-bin, which is required.
Binlog-do-db = db_test: specifies which databases need logs. Each row has one log. If this parameter is not specified, all databases are used by default.
[Mysqld]
Log-bin = mysql-bin
Binlog-do-db = db_test
Binlog-do-db = db_test2
3. delete binary logs:
Mysql> reset master (clear all binary log files)
Purge master logs to 'MySQL-bin.000006 '; (delete binary log files before mysql-bin.000006)
Purge master logs before '2017-08-10 04:07:00 '(delete logs before this date)
In the my. cnf configuration file [mysqld], add:
Expire_logs_day = 3 set the log expiration days. after the specified days, the log will be automatically deleted.
4. the recovery operation is shown below.
Note that every time mysql is started, it will regenerate a file similar to the mysql-bin.000003, if your mysql is restarted every day, then you should pay special attention not to select the wrong log file.
Tip 1:
You can use