Reputation:
I am inserting some non-ascii(specifically asian characters into mysql table column with charset utf8, but after insertion, if I retrieve it again, it shows up as ????. I checked the db, table and column charset, they are all utf8. what's wrong?
CREATE TABLE `test_utf` ( `test_id` bigint(20) NOT NULL auto_increment, `raw_text` longtext, PRIMARY KEY (`test_id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; insert into test_utf (raw_text) values('黄剑');
Upvotes: 2
Views: 1546
Reputation:
Problem solved!
I need to add characterEncoding=UTF-8
to whatever mysql client I'm using,
for example, when I use jdbc
I need to specify "jdbc:mysql://localhost/dbname?characterEncoding=UTF-8"
in connection url.
Upvotes: 3