less than 1 minute

Fix MySQL UTF-8 encoding

Ever had problems with utf-8 encoded characters in a mysql table? You're not alone! 3 easy sql commands might help...

Published Apr 12, 2012 in sql with tags: encoding fix software sql alter table utf8
Scroll

Problem

I recently had the problem with wrong encoded chinese characters which looked like this:

多选型 PersonalFit 中号、大号、超大号

Solution

I’ve tried several ways to fix the encodings but one easy solution solved my problem: I had to convert the affected table columns three times.

  1. Convert to latin1
  2. Convert to blob
  3. Convert back to utf8<

So, if you have a column called name in your table, the following sql script to do the trick:

ALTER TABLE products CHANGE name name TEXT CHARACTER SET latin1;
ALTER TABLE products CHANGE name name BLOB;
ALTER TABLE products CHANGE name name TEXT CHARACTER SET utf8;

After checking the values again the encoding should now be correct like mine:

多选型 PersonalFit 中号、大号、超大号

Hopefully now your problem’s solved :)

2 minutes

myPad - Build your own clipboard out of an old MacBook Pro

Ever wondered what one can do with an old, broken MacBook Pro (pre-unibody)?

Published Mar 22, 2012 in diy