Enable binary mode while restoring a Database from an SQL dump

后端 未结 17 1643
耶瑟儿~
耶瑟儿~ 2020-12-07 14:41

I am extremely new to MySQL and am running it on Windows. I am trying to restore a Database from a dumpfile in MySQL, but I get the following error:

$ >m         


        
17条回答
  •  遥遥无期
    2020-12-07 15:03

    I meet the same problem in windows restoring a dump file. My dump file was created with windows powershell and mysqldump like:

    mysqldump db > dump.sql

    The problem comes from the default encoding of powershell is UTF16. To look deeper into this, we can use "file" utility of GNU, and there exists a windows version here.
    The output of my dump file is:

    Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators.

    Then a conversion of coding system is needed, and there are various software can do this. For example in emacs,

    M-x set-buffer-file-coding-system

    then input required coding system such as utf-8.

    And in the future, for a better mysqldump result, use:

    mysqldump -r

    and then the output is handled by mysqldump itself but not redirection of powershell.

    reference: https://dba.stackexchange.com/questions/44721/error-while-restoring-a-database-from-an-sql-dump

提交回复
热议问题