MySQL Backup and recovery

Source: Internet
Author: User
Tags log log mysql backup

1.1mysql Bin-log Log
MySQL's bin-log log is a database statement that records data additions and deletions. As a result, bin-log can be used as a database recovery file, which is also the basis for MySQL's master-slave replication.
1.1.1 Turn on MySQL's bin-log log
Vi/etc/my.cnf
Log-bin=mysql-bin//Add this statement and restart MySQL
1.1.2 To see if Bin-log is turned on:
Mysql>show variables like '%bin% ';

1.2.3.mysql of Bin-log Log Management
Mysql>flush logs; There will be a new Bin-log log at this time.
Mysql>show Master status; View Bin-log logs currently in use
Mysql>reset master; Clear all logs
1.2.4 Backup and recovery of data with Bin-log
Back up the database: The test database is named tests and the table is T.
Mysqldump–uroot–p test–l–f > '/tmp/test.sql '

-l Lock table,-F is to refresh the Bin-log log so that it can be restored to the backup time with the log before the refresh
Mysql>insert into t values (1); Insert a new record
Mysq>flush logs;
Mysql>drop table T; Delete a table
Recovering a Database
Mysql Test </tmp/test.sql
If you want to restore a record of the time after the database backup, you need to restore the Bin-log log
Mysqlbinlog mysql-00002.bin |mysql–uroot–p Test! []
Bin-log's log content we can see that it contains position points. The recovery log can also specify position points. --stop-position= "193".

The above is mysqldump backup content, next time in the update!

MySQL Backup and recovery

Related Article

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.