Fix bad encoding on MySQL
Today I had to fix a mysql table where a latin1 column was filled with utf8 encoded data.
The trick was to convert the data back to binary and cast it as utf8, to let know mysql it's utf8 encoded and to convert it properly
update tableName
set fieldName = cast(convert(fieldName, binary) AS CHAR CHARACTER SET utf8);
Hope it helps!
Written by Agustín Gutiérrez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#