Although I set up my web app to be fully compliant with UTF8, I forgot to specify the UTF-8 charset in the PDO settings... It happens that the Chinese characters looks strange in the database/phpmyadmin (ä½ å¥½ for 你好), although they look fine in my web app.
As I finally know the solution (to add the charset in the PDO connection settings), I would like to know if there is an easy way to convert my old data to a proper UTF-8. I found on Stackoverflow the following code that does the job, but it solves the encoding problem column per column, table per table..
UPDATE tablename SET
field = CONVERT(CAST(CONVERT(field USING latin1) AS BINARY) USING utf8);
Does it exist a way to perform such conversion to the whole database?
I precise that my MySQL databases/tables are already configured to use the charset UTF-8.
Thanks!
SHOW CREATE TABLEandSELECT col, HEX(col) ...for some mangled text. That is needed to determine whether it is Mojibake or Double Encoding (which is messier to fix). See this for some discussion.你好is hexE4BDA0E5A5BDif correctly stored as utf8; it would be hexC3A4C2BDC2A0C3A5C2A5C2BDif "double encoded". Before attempting to fix the data, we need to distinguish the two cases.