简体   繁体   English

Mysql ERROR: ASCII '\0' while importing sql file on linux server

[英]Mysql ERROR: ASCII '\0' while importing sql file on linux server

I am getting following error while importing sql file导入 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: ''.

How do I fix this?我该如何解决?

Try something like :尝试类似:

mysql -u root -p -h localhost -D database --binary-mode -o < dump.sql

and make sure your sql file is not zipped .并确保您的 sql 文件未压缩

I encountered this problem,the sql file was in a valid ISCII format, I solved as the following:我遇到了这个问题,sql文件是有效的iscii格式,我解决如下:

1- in shell use file command to detect type of data contained in the dump file: 1- 在 shell 中使用file命令来检测转储文件中包含的数据类型:

file db.sql

got output like following:得到如下输出:

db.sql: Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators

2- convert the existing dump file to UTF8 (ASCII) using iconv: 2- 使用 iconv 将现有转储文件转换为 UTF8 (ASCII):

iconv -f utf-16 -t utf-8 db.sql > db_utf8.sql

then import the new file.然后导入新文件。

I just had this issue because the file was gzipped.我刚刚遇到了这个问题,因为文件被压缩了。 I unzipped it and had no further issue.我把它解压缩了,没有进一步的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM