user319198
user319198

Reputation:

How to insert chinese character in mysql table?

I want to save data in Chinese language in mysql table.

Can anyone tell me what settings I have to do for it in mysql and PHP.

My table will save data in both English and Chinese some column English other Chinese . Is it possible with single table.

Any help will be appreciated.

Upvotes: 5

Views: 22159

Answers (3)

Raymond
Raymond

Reputation: 1429

It works perfectly all right, but you have to set the character set and collation of the table BEFORE you insert any chinese characters.

mysql> create table foo (v varchar(10)) CHARACTER SET utf8 COLLATE utf8_general_ci; 

Query OK, 0 rows affected (0.00 sec) 

mysql> insert into foo values('雷蒙德'); Query OK, 1 row affected (0.00 sec) 

mysql> select * from foo; 

+-----------------------+ 

| v | 

+-----------------------+ 

| 雷蒙德 | 

+-----------------------+ 

1 row in set (0.00 sec)

Upvotes: 0

Guixing Bai
Guixing Bai

Reputation: 350

Use UTF-8 when you create table

create table xxx ()CHARACTER SET = utf8;

Use UTF-8 when you insert to table

set names utf8; insert into xxx (xx,x);

Upvotes: 11

Starx
Starx

Reputation: 78961

Set the character set to UTF-8, in mysql.

Check this for reference

http://confluence.jetbrains.net/display/TCD/Configuring+UTF8+Character+Set+for+MySQL http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html

Upvotes: 1

Related Questions