在命令行中保存中文数据时报错data to long for column fname at row1

时间:2021-09-02 10:43:36

 建表语句是

create table T_SupplyType(
    fid int not null primary key auto_increment,
    fnumber varchar(20)  not null,
    fname         varchar(50)     not null,
    fremark     varchar(100)
);

添加记录是insert into T_SupplyType (fnumber,fname) value ('01','测试');

运行时报data to long for column fname at row1,好像我的长度是50,不会不够,后来查了一下,现在如下方案解决:(在window环境下)

1、安装时指定用utf8

2、登录时指定用gbk(utf8是不行的)mysql -u root -p --default-character-set=gbk

3、建库时指定用utf8;   create database yxdb default character set utf8;