MysqlDump from Powershell and Windows encoding

后端 未结 1 992
轻奢々
轻奢々 2021-02-14 09:35

I\'m doing an export from command line on ms-dos with mysqldump:

& mysqldump -u root -p --default-character-set=utf8 -W -B dbname 
> C:\\mysql_backup.sql
         


        
相关标签:
1条回答
  • 2021-02-14 10:25

    By default PowerShell represents text as Unicode and when you save it to a file it saves as Unicode by default. You can change the file save format by using the Out-File cmdlet instead of the > operator e.g.:

    ... | Out-File C:\mysql_backup.sql -Encoding UTF8
    

    You may also need to give PowerShell a hint on how to interpret the UTF8 text coming from the dump utiltiy. This blog post shows how to handle this scenario in the event the utility isn't outputting a proper UTF8 BOM.

    0 讨论(0)
提交回复
热议问题