3 ms·
A nice little clever way to fix this problem so things are actually stored correctly in the tables: run mysqldump and tell it you want to dump to latin1. It wil
by zerocrates 5y ago
A nice little clever way to fix this problem so things are actually stored correctly in the tables: run mysqldump and tell it you want to dump to latin1. It will do the same charset conversion that "fixes" the data here when setting the connection charset, so it will actually dump UTF-8 out. Then just edit the dump and change the SET NAMES line to "utf8mb4" instead of latin1. Loading in that dump should get you correctly-encoded UTF-8 text.
Then you can take the latin1 connection charset out of your app, or replace it with an explicit utf8/utf8mb4 one.
You can do a whole "convert to latin1, then binary, then back to utf8" dance live on the server too but this is cooler.