当前位置:Gxlcms > mysql > mysql-MySQL字符编码问题求解

mysql-MySQL字符编码问题求解

时间:2021-07-01 10:21:17 帮助过:35人阅读

mysql数据库

首先表的创建语句如下:
create table teacher(id int primary key auto_increment,name varchar(40))DEFAULT CHARSET=utf8;
_MySQL中:show variables like 'char%' ;显示如下:
+--------------------------+---------------------------------------------------------------+
| Variable_name | Value |
+--------------------------+---------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\Program Files (x86)\MySQL\MySQL Server 5.0\share\charsets\ |
+--------------------------+---------------------------------------------------------------+

随便插入一个中文数据仍然出现错误,求解。
mysql> insert into teacher values(1,'周');
ERROR 1406 (22001): Data too long for column 'name' at row 1

人气教程排行