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

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

我在导入 sql 文件时遇到以下错误

ERROR: ASCII '[=10=]' 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 '[=10=]' is expected. Query: ''.

需要帮助...!!

试试类似的东西:

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

并确保您的 sql 文件 is not zipped

我遇到了这个问题,sql文件是有效的ISCII格式,我解决如下:

1-在shell中使用file命令检测转储文件中包含的数据类型:

file db.sql

得到如下输出:

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

2- 使用 iconv:

将现有转储文件转换为 UTF8 (ASCII)

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

然后导入新文件。

我刚遇到这个问题是因为文件被 gzip 压缩了。我解压缩了它,没有进一步的问题。