关于mysql二进制文件转换成文本文件

东云180 2011-01-30 04:18:26
如题。
请教各位,如何把binlog.000001二进制日志文件转换成文本文件;在网上找了一些的方法。进行转换,文件是出来了。可是不是
binlog.000004 4 Format_desc 1 98 Server ver: 5.0.18-nt-log, Binlog ver: 4
binlog.000004 243 Intvar 1 271 INSERT_ID=0
binlog.000004 425 Query 1 570 use `mytest`; update managervisitinfo set visitCount=visitCount+1 where visitIP='192.168.4.21'
这些数据。
...全文
782 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
东云180 2011-01-31
  • 打赏
  • 举报
回复
Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.

C:\Documents and Settings\Administrator>cd "d:\mysql server 5.0\bin"

C:\Documents and Settings\Administrator>D:

D:\MySQL Server 5.0\bin>mysqlbinlog "binlog.000009">t9.txt;
mysqlbinlog: File 'binlog.000009;' not found (Errcode: 2)

D:\MySQL Server 5.0\bin>
ACMAIN_CHM 2011-01-31
  • 打赏
  • 举报
回复


楼主你先输入如下命令 , 注意仅是粗体部分。

D:> cd "d:\MySQL Server 5.0\bin"
D:\MySQL Server 5.0\bin> mysqlbinlog "binlog.000009">test9.txt
东云180 2011-01-31
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 feixianxxx 的回复:]

环境变量设置对了么?
直接应该可以在cmd里面 打入 mysqlbinlog...
[/Quote]
环境变量如何设置呀!请指点!谢了!
东云180 2011-01-31
  • 打赏
  • 举报
回复
D:\>MySQL Server 5.0\bin\mysqlbinlog "binlog.000009">test9.txt;
test9.txt的数据结果还是和上面的一样。
nvaicat查询出来的结果是:
binlog.000009 4 Format_desc 1 98 Server ver: 5.0.18-nt-log, Binlog ver: 4
binlog.000009 98 Query 1 262 use `mytest`; create table aname2 (name1 varchar(12) character set gbk,name2 varchar(12) character set utf8)/*!*/
binlog.000009 262 Query 1 344 use `mytest`; drop table aname1
binlog.000009 344 Query 1 426 use `mytest`; drop table aname2
binlog.000009 426 Query 1 585 use `mytest`; create table aname1 (name1 varchar(12) character set gbk,name2 varchar(12) character set utf8)
feixianxxx 2011-01-31
  • 打赏
  • 举报
回复
环境变量设置对了么?
直接应该可以在cmd里面 打入 mysqlbinlog...
小小小小周 2011-01-31
  • 打赏
  • 举报
回复
楼主 仔细看 6楼的内容,


create table aname1 (name1 varchar(12) character set gbk,name2 varchar(12) character set utf8)
和 红字标明 的地方
东云180 2011-01-31
  • 打赏
  • 举报
回复
D:\MySQL Server 5.1\bin\mysqlbinlog "binlog.000001">test2.txt;转换过来的。还是和上面的结果一样!~郁闷呀!
小小小小周 2011-01-31
  • 打赏
  • 举报
回复
D:\MySQL Server 5.1\bin\mysqlbinlog 前面改成这样`
东云180 2011-01-31
  • 打赏
  • 举报
回复
谢谢各位!
东云180 2011-01-31
  • 打赏
  • 举报
回复

就直接在命令提示中D:\MySQL Server 5.1\DATA>mysqlbinlog "mysql-bin.000001" > asd.txt输入这句吗!
直接用这句得到的结果:MySQL Ver 14.12 Distrib 5.0.18, for Win32 (ia32)
Copyright (C) 2002 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Usage: MySQL [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
-A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get
table and field completion. This gives a quicker start of
mysql and disables rehashing on reconnect. WARNING:
options deprecated; use --disable-auto-rehash instead.
-B, --batch Don't use history file. Disable interactive behavior.
(Enables --silent)
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
-C, --compress Use compression in server/client protocol.
-#, --debug[=#] This is a non-debug version. Catch this and exit
-D, --database=name Database to use.
--delimiter=name Delimiter to be used.
-e, --execute=name Execute command and quit. (Disables --force and history
file)
-E, --vertical Print the output of a query (rows) vertically.
-f, --force Continue even if we get an sql error.
-g, --no-named-commands
Named commands are disabled. Use \* form only, or use
named commands only in the beginning of a line ending
with a semicolon (;) Since version 10.9 the client now
starts with this option ENABLED by default! Disable with
'-G'. Long format commands still work from the first
line. WARNING: option deprecated; use
--disable-named-commands instead.
-G, --named-commands
Enable named commands. Named commands mean this program's
internal commands; see mysql> help . When enabled, the
named commands can be used from any line of the query,
otherwise only from the first line, before an enter.
Disable with --disable-named-commands. This option is
disabled by default.
-i, --ignore-spaces Ignore space after function names.
--local-infile Enable/disable LOAD DATA LOCAL INFILE.
-b, --no-beep Turn off beep on error.
-h, --host=name Connect to host.
-H, --html Produce HTML output.
-X, --xml Produce XML output
--line-numbers Write line numbers for errors.
-L, --skip-line-numbers
Don't write line number for errors. WARNING: -L is
deprecated, use long version of this option instead.
--no-tee Disable outfile. See interactive help (\h) also. WARNING:
option deprecated; use --disable-tee instead
-n, --unbuffered Flush buffer after each query.
--column-names Write column names in results.
-N, --skip-column-names
Don't write column names in results. WARNING: -N is
deprecated, use long version of this options instead.
-O, --set-variable=name
Change the value of a variable. Please note that this
option is deprecated; you can set variables directly with
--variable-name=value.
--sigint-ignore Ignore SIGINT (CTRL-C)
-o, --one-database Only update the default database. This is useful for
skipping updates to other database in the update log.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
-W, --pipe Use named pipes to connect to server.
-P, --port=# Port number to use for connection.
--prompt=name Set the mysql prompt to this value.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-q, --quick Don't cache result, print it row by row. This may slow
down the server if the output is suspended. Doesn't use
history file.
-r, --raw Write fields without conversion. Used with --batch.
--reconnect Reconnect if the connection is lost. Disable with
--disable-reconnect. This option is enabled by default.
-s, --silent Be more silent. Print results with a tab as separator,
each row on new line.
--shared-memory-base-name=name
Base name of shared memory.
-S, --socket=name Socket file to use for connection.
-t, --table Output in table format.
-T, --debug-info Print some debug info at exit.
--tee=name Append everything into outfile. See interactive help (\h)
also. Does not work in batch mode.
-u, --user=name User for login if not current user.
-U, --safe-updates Only allow UPDATE and DELETE that uses keys.
-U, --i-am-a-dummy Synonym for option --safe-updates, -U.
-v, --verbose Write more. (-v -v -v gives the table output format).
-V, --version Output version information and exit.
-w, --wait Wait and retry if connection is down.
--connect_timeout=# Number of seconds before connection timeout.
--max_allowed_packet=#
Max packet length to send to, or receive from server
--net_buffer_length=#
Buffer for TCP/IP and socket communication
--select_limit=# Automatic limit for SELECT when using --safe-updates
--max_join_size=# Automatic limit for rows in a join when using
--safe-updates
--secure-auth Refuse client connecting to server if it uses old
(pre-4.1.1) protocol
--show-warnings Show warnings after every statement.

Default options are read from the following files in the given order:
C:\my.ini C:\my.cnf C:\WINDOWS\my.ini C:\WINDOWS\my.cnf D:\MySQL Server 5.0\my.ini D:\MySQL Server 5.0\my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read

Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
auto-rehash TRUE
character-sets-dir (No default value)
default-character-set utf8
compress FALSE
database (No default value)
delimiter ;
vertical FALSE
force FALSE
named-commands FALSE
local-infile FALSE
no-beep FALSE
host (No default value)
html FALSE
xml FALSE
line-numbers TRUE
unbuffered FALSE
column-names TRUE
sigint-ignore FALSE
port 3308
prompt mysql>
quick FALSE
raw FALSE
reconnect FALSE
shared-memory-base-name (No default value)
socket (No default value)
table FALSE
debug-info FALSE
user (No default value)
safe-updates FALSE
i-am-a-dummy FALSE
connect_timeout 0
max_allowed_packet 16777216
net_buffer_length 16384
select_limit 1000
max_join_size 1000000
secure-auth FALSE
show-warnings FALSE
东云180 2011-01-31
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 qingyunluck 的回复:]

mr_mablevi:你好!是要先设置什么吗?你的方法看得不是很明白!求指点!谢谢!
[/Quote]
就直接在命令提示中D:\MySQL Server 5.1\DATA>mysqlbinlog "mysql-bin.000001" > asd.txt输入这句吗!
ACMAIN_CHM 2011-01-31
  • 打赏
  • 举报
回复
在手册中直接查看 如何mysqlbinlog


[Quote=MySQL 5.1参考手册]
8.6. mysqlbinlog:用于处理二进制日志文件的实用工具
服务器生成的二进制日志文件写成二进制格式。要想检查这些文本格式的文件,应使用mysqlbinlog实用工具。

应这样调用mysqlbinlog:

shell> mysqlbinlog [options] log-files...
例如,要想显示二进制日志binlog.000003的内容,使用下面的命令:

shell> mysqlbinlog binlog.0000003
输出包括在binlog.000003中包含的所有语句,以及其它信息例如每个语句花费的时间、客户发出的线程ID、发出线程时的时间戳等等。

通常情况,可以使用mysqlbinlog直接读取二进制日志文件并将它们用于本地MySQL服务器。也可以使用--read-from-remote-server选项从远程服务器读取二进制日志。

当读取远程二进制日志时,可以通过连接参数选项来指示如何连接服务器,但它们经常被忽略掉,除非你还指定了--read-from-remote-server选项。这些选项是--host、--password、--port、--protocol、--socket和--user。

还可以使用mysqlbinlog来读取在复制过程中从服务器所写的中继日志文件。中继日志格式与二进制日志文件相同。

在5.11.3节,“二进制日志”中详细讨论了二进制日志。

mysqlbinlog支持下面的选项:

· ---help,-?

显示帮助消息并退出。

· ---database=db_name,-d db_name

只列出该数据库的条目(只用本地日志)。

· --force-read,-f

使用该选项,如果mysqlbinlog读它不能识别的二进制日志事件,它会打印警告,忽略该事件并继续。没有该选项,如果mysqlbinlog读到此类事件则停止。

· --hexdump,-H

在注释中显示日志的十六进制转储。该输出可以帮助复制过程中的调试。在MySQL 5.1.2中添加了该选项。

· --host=host_name,-h host_name

获取给定主机上的MySQL服务器的二进制日志。

· --local-load=path,-l pat

为指定目录中的LOAD DATA INFILE预处理本地临时文件。

· --offset=N,-o N

跳过前N个条目。

· --password[=password],-p[password]

当连接服务器时使用的密码。如果使用短选项形式(-p),选项和 密码之间不能有空格。如果在命令行中--password或-p选项后面没有 密码值,则提示输入一个密码。

· --port=port_num,-P port_num

用于连接远程服务器的TCP/IP端口号。

· --position=N,-j N

不赞成使用,应使用--start-position。

· --protocol={TCP | SOCKET | PIPE | -position

使用的连接协议。

· --read-from-remote-server,-R

从MySQL服务器读二进制日志。如果未给出该选项,任何连接参数选项将被忽略。这些选项是--host、--password、--port、--protocol、--socket和--user。

· --result-file=name, -r name

将输出指向给定的文件。

· --short-form,-s

只显示日志中包含的语句,不显示其它信息。

· --socket=path,-S path

用于连接的套接字文件。

· --start-datetime=datetime

从二进制日志中第1个日期时间等于或晚于datetime参量的事件开始读取。datetime值相对于运行mysqlbinlog的机器上的本地时区。该值格式应符合DATETIME或TIMESTAMP数据类型。例如:

shell> mysqlbinlog --start-datetime="2004-12-25 11:25:56" binlog.000003
该选项可以帮助点对点恢复。

· --stop-datetime=datetime

从二进制日志中第1个日期时间等于或晚于datetime参量的事件起停止读。关于datetime值的描述参见--start-datetime选项。该选项可以帮助及时恢复。

· --start-position=N

从二进制日志中第1个位置等于N参量时的事件开始读。

· --stop-position=N

从二进制日志中第1个位置等于和大于N参量时的事件起停止读。

· --to-last-logs,-t

在MySQL服务器中请求的二进制日志的结尾处不停止,而是继续打印直到最后一个二进制日志的结尾。如果将输出发送给同一台MySQL服务器,会导致无限循环。该选项要求--read-from-remote-server。

· --disable-logs-bin,-D

禁用二进制日志。如果使用--to-last-logs选项将输出发送给同一台MySQL服务器,可以避免无限循环。该选项在崩溃恢复时也很有用,可以避免复制已经记录的语句。注释:该选项要求有SUPER权限。

· --user=user_name,-u user_name

连接远程服务器时使用的MySQL用户名。

· --version,-V

显示版本信息并退出。

还可以使用--var_name=value选项设置下面的变量:


[/Quote]
小小小小周 2011-01-31
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 qingyunluck 的回复:]

mr_mablevi:你好!是要先设置什么吗?你的方法看得不是很明白!求指点!谢谢!
[/Quote]

不需要设置啊,有mysqlbinlog 这个工具即可/
东云180 2011-01-31
  • 打赏
  • 举报
回复
mr_mablevi:你好!是要先设置什么吗?你的方法看得不是很明白!求指点!谢谢!
东云180 2011-01-31
  • 打赏
  • 举报
回复
ACMAIN_CHM:谢谢!呵呵
ACMAIN_CHM 2011-01-31
  • 打赏
  • 举报
回复
D:\MySQL Server 5.0\bin>mysqlbinlog "x:\xxxx\xxxx\data\binlog.000009">t9.txt

红色部分改成你的实际目录! 另外不需要加分号。

楼主需要学习一下基础的命令行操作。
小小小小周 2011-01-30
  • 打赏
  • 举报
回复
mysql中操作:
create table aname1 (name1 varchar(12) character set gbk,name2 varchar(12) character set utf8)

二进制操作:
D:\MySQL Server 5.1\DATA>mysqlbinlog "mysql-bin.000001" > asd.txt

asd的结果是:

# at 106
#110130 17:08:35 server id 1 end_log_pos 260 Query thread_id=7 exec_time=0 error_code=0
use q/*!*/;
SET TIMESTAMP=1296378515/*!*/;
SET @@session.pseudo_thread_id=7/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=0/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
create table aname1 (name1 varchar(12) character set gbk,name2 varchar(12) character set utf8)
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;


这样..
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

东云180 2011-01-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 rucypli 的回复:]

SQL code
mysqlbinlog binlog.000001
[/Quote]我在mysqlbinlog中这样执行转换时提示outfile disabled转换不成功!这是怎么回事咯!
当我在系统命令提示转换可以,但是数据不对了!
东云180 2011-01-30
  • 打赏
  • 举报
回复
用mysqlbinlog binlog.000001>c:\test.txt;转换时提示outfile disabled转换不成功!这是怎么回事咯!
当我在系统命令提示转换可以,但是数据不对了!
加载更多回复(3)
二进制文件转换,Passolo 是目前世界上最流行的软件本地化专业工具之一。它支持众多文件格式,包括可执行程序文件、资源文件和基于 XML 的文件。文本可以被翻译为多种语言,包括亚洲语系(Unicode 码)以及书写方式为从右向左的语言,比如希伯来语和阿拉伯语。 可用 Passolo 本地化的文件格式一览表 Windows 标准资源 (32 位和 64 位)二进制文件 (EXE, DLL, OCX, SYS...)Windows 标准资源 (16 位,比如 Windows 3.1) 二进制文件 (EXE, DLL, SYS...)Windows 标准资源RC 文件 (RC, RC2, DLG...) Windows CE, Pocket PC 移动设备二进制文件 (EXE, DLL...) * XML 文件 包括 XLIFF 文件 (支持 XLIFF) * Microsoft .NET 资源 (Framework 1.x 到 3.x/WPF) 二进制文件 (EXE, DLL, 程序集) 资源文件 (RESX, RESOURCE...) * Borland Delphi/C++ Builder 二进制文件 (EXE, DLL, BPL) (包括对话框和菜单编辑器) * Java 资源 (所有平台 J2EE, J2SE 和 J2ME) 属性文件,源文件二进制文件,方案文件 * Palm 操作系统软件 * ODBC 数据库解析器 支持 ACCESS, Excel, SQL 服务器, Oracle, MySQL, IBM DB2 * Visual BASIC 6 二进制文件 * Visual BASIC 6 方案 (VBP) 和窗体 (FRM) 支持 WYSIWYG 编辑器以及从代码中提取文本 * 通用文本文件解析器 支持许多不同的文件格式和编码 * 可移植对象文件 (PO) 解析器 * Microsoft Installer 文件解析器 支持所有 MSI 文件中的表 * Microsoft Excel 文件解析器 支持所有 Excel 文件中的表单 * XLIFF 配置文件 WYSIWYG 编辑器给 Windows 资源 * 用户定义的文件格式 高度结构化的文本文件二进制文件

56,678

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧