MySQL database recovers data through Bin-log logs

Source: Internet
Author: User
Binlog logs are used to record all update data, and when our database fails, we can use the Binlog log to retrieve it.

If there is a problem with the MySQL database, you need to recreate the Binlog binary file.

# 查看日志,查出需要恢复的时间点mysqlbinlog --no-defaults fangx-bin.000001 |more
#恢复具体时间导成SQL语句mysqlbinlog fangx-bin.000001 --database=fangx --start-datetime=‘2018-06-6 00:00:01‘ --stop-datetime=‘2018-06-6 23:59:59‘   > fangx2018.sql
database   #为要恢复的数据库名称 start-datetime   #恢复的起始时间 stop-datetime   #恢复的结束时间
# 把sql语句导入进去mysql -uroot -pfan fangx -v -f < fangx2018.sql-v   是查看导入的详细信息-f   是当中间遇到错误时,可以skip过去,继续执行下面的语句
# 或者这样直接导入mysqlbinlog --no-defaults fangx-bin.000001 --start-position="794" --stop-position="1055" | mysql -uroot -pfan fangx
 #清除所有binlog日志 从1开始 reset master

MySQL database recovers data through Bin-log logs

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.