欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql-MySQL字符编码问题求解

程序员文章站 2022-05-04 22:45:55
...
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

相关标签: mysql 数据库