MySQL利用mysqlbinlog命令恢复误删除数据
程序员文章站
2022-05-03 14:47:57
MySQL开启binlog功能 2.登录到数据库 3.创建与删除数据库 4.查看binlog日志 5.恢复数据 ......
1.mysql开启binlog功能
log-error=/var/log/mysql.log log-bin=/data/binlog/mysql-bin sync_binlog=1 binlog_format=row
2.登录到数据库
[root@db01 ~]# mysql -uroot -p123
3.创建与删除数据库
mysql> create database xiaohai; mysql> drop database xiaohai;
4.查看binlog日志
[root@db01 binlog]# mysqlbinlog mysql-bin.000008 # at 1200 #200409 16:41:36 server id 10 end_log_pos 1297 crc32 0x84e92ac7 query thread_id=8 exec_time=0 error_code=0 set timestamp=1586421696/*!*/; create database xiaohai /*!*/; # at 1297 #200409 16:42:24 server id 10 end_log_pos 1384 crc32 0xfdf1d747 query thread_id=8 exec_time=0 error_code=0 set timestamp=1586421744/*!*/; drop database xiaohai /*!*/; delimiter ; # end of log file rollback /* added by mysqlbinlog */; /*!50003 set completion_type=@old_completion_type*/; /*!50530 set @@session.pseudo_slave_mode=0*/;
5.恢复数据
[root@db01 binlog]# mysqlbinlog mysql-bin.000008 --start-position=1200 --stop-position=1297>test.sql mysql> source /data/binlog/test.sql; mysql> show databases;
转自:https://www.cnblogs.com/yanyanqaq/p/12675968.html
上一篇: C#中 EF 性能优化
下一篇: JavaScript高级笔记