Question

How to store unicode in MySQL?

How do I store Unicode in free edition of MySQL?

There doesn't seem to be nvarchar type as in SQL Server. Is Unicode not supported in MySQL? I tried using text but that too is not working.

 45  82694  45
1 Jan 1970

Solution

 33

You need to choose a utf8_* character set for your table. Text and memo fields will then automatically be stored in UTF-8. Support for UTF-16 is coming in mySQL 6.

2010-07-25

Solution

 29

The character set for a given string column (CHAR, VARCHAR or *TEXT) is determined by its character set and/or collation. This is a quite intense topic so it's best to read the documentation I linked. For example:

CREATE TABLE t1
(
    col1 CHAR(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci
)

will create a table t1 with a col1 that stores its content in UTF-8 encoding.

2010-07-25