2

I'm trying to use Chinese characters in mysql table. On my first try I wrote something like 中文考试 and my table came back with 还有一个考试.

After research, it was suggested that I use the UTF-8 as my character set. I went back to my table and altered the character set with the command

ALTER TABLE posts CONVERT TO CHARACTER SET utf8;

I tried writing Chinese characters again and got the same result - ( 还有一个考试.).

Here is a copy of my table as it exist right now:

enter image description here

How can I get my table to accept Chinese characters?

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
jonjon
  • 121
  • 2
  • 10
  • possible duplicate of [How to make MySQL handle UTF-8 properly](http://stackoverflow.com/questions/202205/how-to-make-mysql-handle-utf-8-properly) – Joe Jun 13 '14 at 01:54

1 Answers1

2

After research, it was suggested that I use the UTF-8 as my character set.

You need to make sure your entire chain from the connection, to the database, to the tables is all UTF8 clean. I have a detailed answer to a similar question here.

But in your case, check the actual MySQL server my.cnf file. The following would set the whole chain to UTF-8:

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

The my.cnf is the main MySQL configuration file. Depending on your OS it can be located in a few places. For example in Ubuntu 12.04 it can be found here:

/etc/mysql/my.cnf

So figure out where yours is located, open up that file, edit it, restart MySQL & you should be good to go.

Community
  • 1
  • 1
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103