Se si esporta un database MySQL usando mysqldump in una PowerShell di Windows con il redirect
mysqldump.exe <nomedb> > <nomefile>
poi quando si va a reimportarlo da MySQL sotto Linux questo dà errore:
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: ‘SQLite format 3’.
anche impostando il –binary-mode, il comando di restore dà comunque errore:
ERROR at line 1: Unknown command ‘\☻’
Questo è dovuto a una caratteristica della PowerShell, che crea dei file in UTF16. Lo si vede con file:
Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators.
Per evitare questo problema, conviene usare una modalità di esportazione diversa con mysqldump:
mysqldump <nomedb> -r <nomefile>
In questo modo il file generato può essere ripristinato senza errori da Linux.