简体   繁体   中英

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.

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);

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM