Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 856
zish Avatar asked Jul 14 '16 20:07

zish


People also ask

How do you change binary mode to 1?

Set --binary-mode to 1 if ASCII '\0' is expected.


2 Answers

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.

like image 64
Eric BELLION Avatar answered Sep 21 '22 07:09

Eric BELLION


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.

like image 37
Zeid Al-Rashwani Avatar answered Sep 21 '22 07:09

Zeid Al-Rashwani