Converting a file from Windows format (utf-16) to Ubuntu format (utf-8)

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