Last Updated: February 25, 2016
·
285
· asimabdul

MySQL - Change table encoding

Table encoding maybe an issue when dealing with foreign language data. Unicode needs to be the encoding format and there is a chance your table is not.

Here is the DDL to do a conversion to UTF8:

ALTER TABLE {table_name} CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

utf8 and utf8_general_ci is a character_set\server and collationserver respectively.

These values can be looked up in MySQL using:

show variables like 'character_set_server';

show variables like 'collation_server';