UTF-8 strings in a MySQL database got messed up after configuration change

后端 未结 2 1496

I have a MySQL with strings that I left dormant for a while. Now that I picked it up again, I noticed that all the special characters are screwed up. My ISP has ported the serve

2条回答
  •  情歌与酒
    2021-02-10 18:26

    I suspect you might have your characters stored as UTF8 strings in a latin1 (or similar) database. That's why you've got 'double encoding' problem. Making the database's CHARSET UTF8 should fix it. Dumping/importing the data might be necessary as well, something along those lines:

    $ mysqldump --default-character-set=latin1  --skip-set-charset --databases xxx > xxx.sql
    $ mysql --default-character-set=utf8 < xxx.sql
    

    But that's just suggestion, might work but don't have to in your specific case.

提交回复
热议问题