0

This has been asked before and answered: How to convert an entire MySQL database characterset and collation to UTF-8?

The right answer is along the lines of:

ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

However, there is a comment on that answer, which describes the problem I am facing:

The CONVERT TO technique assumes that the text was correctly stored in some other charset (eg, latin1), and not mangled (such as UTF-8 bytes crammed into latin1 column without conversion to latin1). – Rick James Apr 19, 2017 at 16:03

I have a table that uses cp1252 encoding and latin1_bin collation. It stores "Pelé" instead of "Pelé". After running the above command, such mangled text has no change so it remains mangled. If it matters, the reading application is on PHP.

How can I fix my data in the database?

Dharman
  • 30,962
  • 25
  • 85
  • 135
tinkerr
  • 975
  • 2
  • 14
  • 32
  • How are you setting the connection charset when connecting to MySQL from your PHP application? There are many layers in play here; if you need to fix existing data, you might have to export, convert and then import it again. – MatsLindh Oct 24 '22 at 06:46
  • 1
    That's Mojibake. Study https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored And the link to possible fixes. – Rick James Oct 24 '22 at 16:06

0 Answers0