Mysql accidentally changed the code of a field, resulting in all the stored Chinese garbled, and then want to change it back to utf-8 and found that it can not be changed back. Is there any way to get the data right?

clipboard.png

Mar.21,2022

Old data is ready, but there is hardly any. If you open the log, you can see if the log is normal and import it. Cool without opening


does not post your specific operation. I don't know how you modified the field code. If you reset the CHARSET, of a field with ALTER TABLE , for example:

ALTER TABLE `table` CHANGE `column` VARCHAR(255) CHARACTER SET latin1;

and then change it back to utf8, then the data must be lost (this is because when converting between different encodings, if you encounter bytes that fail to convert, you will use similar? Or cancel instead, so that when you convert it back, it will not be the original byte)

if you only use SET NAMES latin1 to change the database code or modify the encoding-related constants (for example: character_set_results ), at this time, although you may query the garbled code, you can recover it through SET NAMES utf8 .

Menu