← Back to team overview

maria-discuss team mailing list archive

Re: Converting the whole database and tables from one charset+collation to another

 



On 12/10/2014 01:48 PM, Honza Horak wrote:
Google does not provide any source I would be sure of, many different
approaches.. so rather asking here..

Given I have a database with latin1 and some latin* collation, the same
for tables and I want to convert database, tables and data to utf8.

Are the following two commands really all I need to do? I mean if that
is really enough to change the data as well..

   ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE
utf8_unicode_ci;

Note, ALTER DATABASE does not convert any tables.
It only changes the database default character set and collation.
They will be used as defaults for all "CREATE TABLE" executed
after this ALTER DATABASE.

So, you need to loop ALTER TABLE (like the one below) for all tables
you want to convert.


   ALTER TABLE db_table CONVERT TO CHARACTER SET utf8 COLLATE
utf8_unicode_ci;

Thanks ahead for clarification.

Honza

_______________________________________________
Mailing list: https://launchpad.net/~maria-discuss
Post to     : maria-discuss@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~maria-discuss
More help   : https://help.launchpad.net/ListHelp


References