HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

change encoding of database from latin1_swedish_ci to utf8

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
utf8latin1_swedish_cidatabaseencodingfromchange

Problem

I have an huge database in latin1_swedish_ci. Now i need to convert all data to utf8 collation.

My question is about the consistency of the information. When I do this change it is possible corrupt the data that is in database?

something like this:

mysql> alter database user_db default character set utf8 collate utf8_unicode_ci;


there is any risk of changing the information?

Solution

If you have any stored procedures that use database defaults, you must drop and recreate those stored procedures.

If the ALTER DATABASE command runs quickly, chances are the tables were not altered.

You may have to run ALTER TABLE on all your tables as follows:

ALTER TABLE tblname CONVERT TO CHARACTER SET charset_name [COLLATE collation_name];

Code Snippets

ALTER TABLE tblname CONVERT TO CHARACTER SET charset_name [COLLATE collation_name];

Context

StackExchange Database Administrators Q#24453, answer score: 2

Revisions (0)

No revisions yet.