Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing database encoding with existing data

If I change the encoding of my database, tables and related columns from latin1_swedish_ci (default) to utf8_general_ci to show European and other characters, will that apply to any existing data, or only to new inserts?

I currently have names showing up as Rubén which don't fix themselves even when changing that column's encoding to utf8_general_ci.

Do I have to re-import my data into the database, or can I apply encoding changes to existing data 'in-place'?

like image 456
Bojangles Avatar asked Aug 13 '26 05:08

Bojangles


1 Answers

This might help:

UPDATE table SET column=CONVERT(CONVERT(column USING binary) USING utf8) WHERE id=123;

Source: http://www.mysqlperformanceblog.com/2007/12/18/fixing-column-encoding-mess-in-mysql/

like image 97
Ortiga Avatar answered Aug 16 '26 19:08

Ortiga



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!