Converting MySQL tables to utf8 encoding format

June 1, 2017

You specify an encoded character set when you create a database. Choosing a character set determines what languages can be represented in the database.

Before beginning any conversion, please back up your database.

Convert MySQL tables to utf8 encoding format:

ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

If you already have MySQL database dump containing characters written in some other character encoding type the solution would be this:

alter table TABLE_NAME modify FIELD_NAME blob;
alter database DATABASE_NAME charset=utf8;
alter table TABLE_NAME modify FIELD_NAME varchar(255) character set utf8;

This forces MySQL to convert the binary format into varchar using character set utf8.

Previous post:

Next post: