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

倖福魔咒の 提交于 2020-02-13 08:38:05

问题


I am getting following error while importing sql file

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

HELP NEEDED...!!


回答1:


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.




回答2:


I encountered this problem,the sql file was in a valid ISCII format, I solved as the following:

1- in shell use file command to detect type of data contained in the dump 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:

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

then import the new file.



来源:https://stackoverflow.com/questions/38383975/mysql-error-ascii-0-while-importing-sql-file-on-linux-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!