use*_*997 16 mysql mysqldump restore
我对 MySQL 非常陌生,正在 Windows 上运行它。我正在尝试从 MySQL 中的转储文件恢复数据库,但出现以下错误:
$ >mysql -u root -p -h localhost -D database -o < dump.sql
ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: 'SQLite format 3'.
Run Code Online (Sandbox Code Playgroud)
我试过了,$ > mysql -u root -p -h localhost -D database --binary-mode -o < dump.sql
但这给了我以下内容ERROR at line 1: Unknown command '\?'.
这是一个 500 Mb 的转储文件,当我使用 gVIM 查看其内容时,我只能看到无法理解的表达式和数据。此外,当我尝试从文件中复制内容以在此处发布时,我只能复制:SQLite format 3
这种看起来很奇怪。
Mic*_*bot 20
对--binary-mode
(在 MySQL 5.6.3 中引入)的引用可能会分散注意力。
这听起来不像你在处理一个 mysqldump 输出文件,那里。试试这个file
实用程序。
shell> file dumpfile.sql
dumpfile.sql: ASCII text
Run Code Online (Sandbox Code Playgroud)
如果您没有得到ASCII text
响应,那么您正在处理根本不是转储文件的内容mysqldump
,或者您正在处理已压缩的内容(例如,使用 gzip 或 bzip2),您d 需要在管道进入之前解压缩mysql
。
如果你看到SQLite 3.x database
那么你肯定有你的答案......它是一个原始的 SQLite 数据库,而不是一个 MySQL 转储文件。
实际上,SQLite 数据库的前几个字节是:
53 51 4C 69 74 65 20 66 SQLite f
6F 72 6D 61 74 20 33 00 ormat 3^@
Run Code Online (Sandbox Code Playgroud)
请注意,这里的第 16 个八位字节是 0x00,解释了ERROR: ASCII '\0' appeared in the statement...
这种情况下的消息。--binary-mode
适当的建议是虚惊一场。
Windows 用户:'file' 实用程序是来自 Unix 的工具,但可以在此处找到 Windows 版本。
小智 7
使用此命令创建转储文件
.\mysqldump [dbname] -r [filename.sql]
Run Code Online (Sandbox Code Playgroud)
使用:
.\mysqldumb --help
Run Code Online (Sandbox Code Playgroud)
-r, --result-file=name
Direct output to a given file. This option should be used
in systems (e.g., DOS, Windows) that use carriage-return
linefeed pairs (\r\n) to separate text lines. This option
ensures that only a single newline is used.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
61773 次 |
最近记录: |