Mysqlbinlog使用
来源:互联网 发布:个性化排序算法 编辑:程序博客网 时间:2024/04/25 23:05
在my.cnf这个文件中加一行(Windows为my.ini)。
#vi /etc/my.cnf
[mysqld]
log-bin=mysqlbin-log #添加这一行就ok了=号后面的名字自己定义吧
然后我们可以对数据库做简单的操作后到mysql数据文件所在的目录来看binlog文件。
2. 查看自己的BINLOG的名字是什么
命令:show binarylogs
3. 做了几次操作后,它就记录了下来。
命令:showbinlog events
4. 用mysqlbinlog工具来显示记录的二进制结果,然后导入到文本文件,为了以后的恢复。
详细过程如下:
C:\Program Files\MySQL\MySQL Server5.0\bin>mysqlbinlog --start-position=4--sto
p-position=106 mysqlbin-log.000001 >c:\\test1.txt
或者全部导出:
C:\ProgramFiles\MySQL\MySQL Server 5.0\bin>mysqlbinlogmysqlbin-log.000001 > c:\\test1.txt
test1.txt的文件内容:
;
;
DELIMITER ;
# at4
#110916
# Warning:this binlog was not closed properly. Most probably mysqld crashedwriting it.
ROLLBACK;
# at98
#11091610:11:21 server id 1
SETINSERT_ID=2;
# at126
#11091610:11:21 server id 1
usetest;
SET TIMESTAMP=1316139081;
SET@@session.foreign_key_checks=1, @@session.sql_auto_is_null=1,@@session.unique_checks=1;
SET@@session.sql_mode=1344274432;
;
SET@@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8;
insertinto User (name,password) values('ddd','222');
DELIMITER ;
# End oflog file
ROLLBACK;
;
5. 导入结果到MYSQL中进行数据恢复。
C:\ProgramFiles\MySQL\MySQL Server 5.0\bin>mysqlbinlog--start-position=134 --stop-position=330 mysqlbin-log.000001 |mysql -uroot -p
或者
C:\ProgramFiles\MySQL\MySQL Server 5.0\bin>mysqlbinlog--start-position=134 --stop-position=330 mysqlbin-log.000001>test1.txt
进入MYSQL导入
mysql> source c:\\test1.txt
还有一种办法是根据日期来恢复
C:\ProgramFiles\MySQL\MySQL Server 5.0\bin >mysqlbinlog--start-datetime="2009-09-14 0:20:00" --stop-datetim="2009-09-1501:25:00" /diskb/bin-logs/xxx_db-bin.000001 | mysql -uroot
6、查看数据
Select *from User
- Mysqlbinlog 使用
- Mysqlbinlog使用
- Mysqlbinlog 使用
- mysqlbinlog使用
- mysql mysqlbinlog的使用
- mysqlbinlog的使用
- mysqlbinlog使用详解
- mysqlbinlog的使用
- 三、 mysqlbinlog使用简介
- mysqlbinlog 命令简单使用
- mysqlbinlog的使用
- Mysqlbinlog
- mysqlbinlog
- mysqlbinlog
- mysqlbinlog
- 使用mysqlbinlog工具恢复数据
- 使用 MYSQLBINLOG 来恢复数据
- mysql 数据库 mysqlbinlog 使用步骤
- 那些年干过的事(序)
- bitnami-redmine-2.x 安装插件
- 黑马程序员--银行业务调度
- 编译Qt 4.8.5
- 需求-谁说了算!
- Mysqlbinlog使用
- PL/SQL Developer导入导出数据库方法及说明
- Java IO体系之强大的RandomAccessFile
- java 调用webservice时抛异常(Fault occurred while processing)的解决方案
- jstl fmt标签的使用
- EXCEL技巧
- hdu 1429胜利大逃亡(续)
- 基于单幅图像的2D转3D算法研究
- ipc 通讯之ftok