Linux recovers databases via MySQL binary log binlog

Source: Internet
Author: User

Linux recovers databases via MySQL binary log binlog

Go to MySQL

See if MySQL logs are started

Go to MySQL

Mysql>show variables like ' log_% ';

The following binary log setup methods for Linux are as follows

In the/etc/my.cnf file, under "Mysqld", add

Server-id = 1

Log-bin = Binlog

Log-bin-index = Binlog.index

Binlog log file defaults to/var/lib/mysql

View Binlog log file commands

Mysqlbinlog binlog.000001

To view the Binlog file, filter for error actions, such as the Delete data table operation on line No. 2586, use the SQL statement before 2586

Methods are as follows

Mysqlbinlog--stop-position= "2586"/var/lib/mysql/binlog.000001 >~/nn/backup_001.sql

Restores

Mysql–u Root–p Nsq_name < ~/nn/backup_001.sql

Note Be sure to note the spaces and capitalization

Other:

Linux Backup Database

1. Backup

1 [[Email protected] ~]# mysqldump-u root-p mysql > ~/mysql.sql #把数据库mysql备份到家目录下命名为mysql. sql

2 Enter Password:

3 [[email protected] ~]# ls ~/mysql.sql

/root/mysql.sql

2. Restore

[Email protected] ~]# mysql-u root-p Web < ~/web.sql #把web. SQL Import Database Web

Common Binlog Log Operations commands

1. View all Binlog log lists      mysql> show master logs;
2. View the master status, which is the last (most recent) one Binlog log's number name, and its last action event Pos end point (Position) value mysql> show Master status;
3. Refresh log log, starting from now to produce a new numbered Binlog log file mysql> flush logs;
Note: Each time the MYSQLD service restarts, this command is automatically executed to refresh the Binlog log;
Adding the-F option to mysqldump backup data also refreshes the Binlog log;
4. Reset (empty) all Binlog logs mysql> reset master;

Linux recovers databases via MySQL binary log binlog

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.