Mysql 错误:在 Linux 服务器上导入 sql 文件时出现 ASCII '\0'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38383975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mysql ERROR: ASCII '\0' while importing sql file on linux server
提问by zish
I am getting following error while importing sql file
导入sql文件时出现以下错误
ERROR: ASCII 'mysql -u root -p -h localhost -D database --binary-mode -o < dump.sql
' 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 '##代码##' is expected. Query: ''.
HELP NEEDED...!!
需要帮助...!!
回答by Eric BELLION
回答by Zeid Al-Rashwani
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
file db.sql
got output like following:
得到如下输出:
db.sql: Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators
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
iconv -f utf-16 -t utf-8 db.sql > db_utf8.sql
then import the new file.
然后导入新文件。