Converting a file from Windows format (utf-16) to Ubuntu format (utf-8)
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
Subscribe to my newsletter
Read articles from Anjanesh Lekshminarayanan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Anjanesh Lekshminarayanan
Anjanesh Lekshminarayanan
I am a web developer from Navi Mumbai working as a consultant for cloudxchange.io. Mainly dealt with LAMP stack, now into Django and trying to learn Laravel and Google Cloud. TensorFlow in the near future. Founder of nerul.in