mysql 1336,无法通过utf8编码在mysql数据库中插入中文(警告1336错误的字符串值)...

I cannot insert Chinese in the table. I have already config the charset and collation as utf8 and utf8_general_ci. The database and table is created as utf8.

Also, I have tried charset as utf8mb4 and collation as utf8_unicode_ci, utf8mb4_general_ci, utf8mb4_unicode_ci. All of them point to same error : warning 1366 Incorrect String value.

Big5 and GBK encoding work in this case but I would like to use utf8, as simplified, traditional chinese will be allow to insert.

some of the code in mysql:

create database db1 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

create table table1 (

lastName varchar(255),

firstName varchar(255)

) ENGINE = MYISAM CHARSET=utf8 COLLATE utf8_general_ci;

INSERT INTO table1 VALUES ('陳','小文');

Warning | 1366 | Incorrect string value: '\xB3\xAF' for column 'lastName' at r

w 1 |

Warning | 1366 | Incorrect string value: '\xA4p\xA4\xE5' for column 'firstName

at row 1 |

configuration in my.ini:

[client]

default-character-set=utf8

[mysqld]

default-storage-engine=MyISAM

collation-server=utf8_general_ci

init-connect='SET NAMES utf8'

character-set-server=utf8

skip-character-set-client-handshake=1

[mysql]

default-character-set=utf8

Using Mysql 5.6.8 version.

解决方案

CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci set this collation on three places:

1- In database collation under operation or setting tab you can find collation dropbox select "utf8mb4_general_ci" from there.

2- In table again under operation tab you need to change collation value from dropdown for same "utf8mb4_general_ci".

3- Don't forget now to change the collation of your column that hold your data click on structure tab of your table edit the columns that need to be hold Chinese data and change collation for each as same: "utf8mb4_general_ci".

Try to place chinese character directly from phpmyadmin if you can successfully insert chinese character that's means you're done with database then try with server or from your website. If doesn't work from wesbite, Then May you need to add utf 8 meta tag on website script.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值