Binlog commands and restoration tips in MySQL _ MySQL

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.