Mysql ERROR: ASCII ” while importing sql file on linux server

I am getting following error while importing sql file

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

How do I fix this?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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.

Method 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.

Method 3

I just had this issue because the file was gzipped. I unzipped it and had no further issue.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x