mysql能插入英文字段,当插入中文字段时出现 ERROR 1406 (22001): Data too long for column 'AdminName' at row 1
错误的解决办法
在mysql命令行窗口中:show variables like '%char%';
+--------------------------+----------------------------------------------------
-----+
| Variable_name | Value
|
+--------------------------+----------------------------------------------------
-----+
| character_set_client | utf8
|
| character_set_connection | utf8
|
| character_set_database | utf8
|
| character_set_results | utf8
|
| character_set_server | utf8
|
| character_set_system | utf8
|
| character_sets_dir | C:/Program Files/MySQL/MySQL Server 5.0/share/chars。。。。。
执行这两条语句,将mysql客户端编码设置为gbk,同时也将结果集results的编码设置为gbk防止乱码
set character_set_client=gbk;
set character_set_results=gbk;