Mysql错误:ASCII' \ 0'在linux服务器上导入sql文件时

时间:2016-07-14 20:46:51

标签: mysql phpmyadmin mysqldump mysqlimport

导入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: ''.

需要帮助...... !!

3 个答案:

答案 0 :(得分:15)

尝试类似:

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

并确保您的sql文件is not zipped

答案 1 :(得分:9)

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

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

file db.sql

输出如下:

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

使用iconv:

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

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

然后导入新文件。

答案 2 :(得分:2)

我只是遇到了这个问题,因为文件已压缩。我解压缩了,没有其他问题了。