Converting a file from Windows format (utf-16) to Ubuntu format (utf-8)
ASCII '\0' appeared in the statement Error

You've exported a MySQL dump (say the file is my-db.sql) from Windows in Powershell or via phpMyAdmin. Now you want to import the MySQL file, my-db.sql, on a Ubuntu machine. You get the error :
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.
Run this command on your Ubuntu machine :
iconv -f utf-16 -t utf-8 my-db.sql > my-db_utf8.sql
Now import my-db.sql via mysql --user=username --database=my-db_utf8 -p < my-db.sql. It should work.
PS: Incase you're not sure what kind of file my-db.sql is, try running file my-sb.sql in the Ubuntu terminal. For example :
file my-db.sql
my-db.sql: Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators
About the author
- I am a web consultant from Navi Mumbai. Mainly dealt with LAMP stack, now into Django and getting into Laravel and Cloud. Founder of nerul.in and gaali.in
Comments
Join the discussionNo comments yet. Be the first to comment.
