Last Updated: February 25, 2016
·
322
· andersonfreitas

Convert a MySQL database to utf8

Convert the charset of the database (this won't convert its tables)

ALTER DATABASE '<MY DATABASE>' CHARSET=utf8

First, get all the table names from your database:

SELECT TABLE_NAME FROM `TABLES` WHERE `TABLE_SCHEMA` LIKE '<MY DATABASE>'

Then, for each table:

ALTER TABLE `<MY TABLE>` CONVERT TO CHARACTER SET utf8;

There's no need to use iconv, php, ruby gems, bash scritps, special procs, just that.

  • Tested with MySQL 5.5