| Showing entries 1 to 5 |
Having covered the preparation and character set options of performing a latin1 to utf8 MySQL migration, just how do you perform the migration correctly.
Just to recap, we have the following example table and data.
mysql> select c,length(c),char_length(c),charset(c), hex(c) from conv.test_latin1; +---------------+-----------+----------------+------------+----------------------------+ | c | length(c) | char_length(c) | charset(c) | hex(c) | +---------------+-----------+----------------+------------+----------------------------+ | a | 1 | 1 | latin1 | 61[Read more...]
The headline is flame-bait, don’t take it. I just wanted to point something out about character sets and collations in MySQL.
To the uninitiated, it may seem overwhelming. Everything has a character set! Everything has a collation! And they act weirdly! The server has one. The database has one (oh, and it changes magically as I USE different databases.) Every table has one, and columns too. Is that all? NO! My connection has one! Kill me now!
Relax. In truth, only one kind of thing actually has a charset/collation. That is values. And values are stored in columns. The only thing that really has a charset/collation is a column.[1]
What about all the rest of those things — connection, database, server, table? Those are just defaults, which determine what charset/collation a
[Read more...]Continuing on from preparation in our MySQL latin1 to utf8 migration let us first understand where MySQL uses character sets. MySQL defines the character set at 4 different levels for the structure of data.
In MySQL 5.1, the default character set is latin1. If not specified, this is what you will get. For example.
mysql> create table test1(c1 varchar(10) not null); mysql> show create table test1\G Create Table: CREATE TABLE `test1` ( `c1` varchar(10) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1
If you want all tables in your instance to always be a default of utf8, you can changed the server variable
[Read more...]Before undertaking such migration the first step is a lesson in understanding more about how latin1 and utf8 work and interact in MySQL. latin1 in a common and historical character set used in MySQL. utf8 (first available in MySQL Version 4.1) is an encoding supporting multiple bytes and is the system default in MySQL 5.0
MySQL has a number of different system variables to consider, the following is the default representation in MySQL 5.1
mysql> show global variables like '%char%';[Read more...]
| Showing entries 1 to 5 |