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?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.