Here’s a problem some or most of us have encountered. You have a
latin1 table defined like below, and your application is storing
utf8 data to the column on a latin1 connection. Obviously, double
encoding occurs. Now your development team decided to use utf8
everywhere, but during the process you can only have as little to
no downtime while keeping your stored data valid.
CREATE TABLE `t` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`c` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
master> SET NAMES latin1;
master> INSERT INTO t (c) VALUES ('¡Celebración!');
master> SELECT id, c, HEX(c) FROM t;
+----+-----------------+--------------------------------+
| id | c | HEX(c) |
+----+-----------------+--------------------------------+
| 3 | ¡Celebración! | C2A143656C656272616369C3B36E21 |
+----+-----------------+--------------------------------+
1 row in set (0.00 sec)
master> SET …[Read more]