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.


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.


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.


Have you tried setting names after connection? What was the outcome of tryng to store unicode characters? Connect to mysql server and type this:

SET NAMES UTF8;

This should turn on "support" for utf8. Then try storing utf data.