易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 3086|回复: 2
收起左侧

ERROR 1406 (22001): Data too long for column 'shell' at row 2 解决办法

[复制链接]
发表于 2020-6-17 15:26:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
mysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by '\n';  
, v1 n) @8 l) TERROR 1406 (22001): Data too long for column 'shell' at row 2: ^: [2 P2 T& j0 S1 E
4 P+ o; E& _7 C* L& [8 `

+ c0 R# N% i# k3 ^2 emysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by '\n';) n3 {1 Y) W6 \+ ^( w3 z' h( N6 ~
ERROR 1406 (22001): Data too long for column 'shell' at row 2
6 U( e' p. ]" w0 b6 x% @5 m7 ?( Y0 h2 o* w0 B% P# H( o  N
Records: 0  Duplicates: 0  Warnings: 0
+ @' O  z4 N6 C1 u9 j2 h. Q
* c7 j/ s' a) Q' lERROR 1406 (22001): Data too long for column 'shell' at row 25 X4 C9 A" ~! f1 @9 b3 n. q
报错提示字符太长,导致数据容量过大。7 Z  {1 c6 k# \& k6 z6 Y. K
解决办法:# M8 K/ k  F7 I$ @* F
modify 修改字段类型1 p' {* Q6 u% Y) U
    modify 字段名 类型(宽度) 约束条件 , modify 修改个多个在后面田间,modify& M4 ]4 r: Z4 a: _+ ~
mysql> alter table six modify shell varchar(50);
  O- h+ t+ K# y3 x) ?& }0 {$ |4 [
' ]1 H. A3 C3 _) @. V# I- GQuery OK, 0 rows affected (1.85 sec)7 Y8 e* Q- i' L+ H3 x3 N, \1 R
Records: 0  Duplicates: 0  Warnings: 0
5 Z* T: |# V* F4 f6 F, q1 z9 S, c; }; {( f
mysql> alter table six modify shell varchar(50);
) h8 Y1 S+ p  w) i3 |5 ^& NQuery OK, 0 rows affected (1.85 sec)& X6 M) `1 ]! b; A

6 Y! R  y- R# `; c! s; r5 V% ^& _mysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by '\n';
2 x" _6 J( |# P+ }$ OQuery OK, 24 rows affected (0.29 sec)" a% |  Q8 x9 u
Records: 24  Deleted: 0  Skipped: 0  Warnings: 0
5 B( \! \$ f$ }! w4 s3 A$ }9 N0 S3 G1 l/ A
 楼主| 发表于 2020-6-17 15:26:47 | 显示全部楼层
mysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by '\n';  
6 n: p& n! X% J# B4 d4 D" u& vERROR 1406 (22001): Data too long for column 'shell' at row 2
  N& ]9 m* y$ w7 N6 Gmysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by'\n';
9 e8 q# e; O5 G* a* @1 H7 MERROR 1406 (22001): Data too long for column 'shell' at row 2! A1 X& U$ w% t  D% b
mysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by '\n';5 Y9 V7 l8 F) j; t
ERROR 1406 (22001): Data too long for column 'shell' at row 2
& a0 p( h2 k' F4 mmysql> alter table six modify shell varchar(50);
* B( L0 B; v; Z. x! ?Query OK, 0 rows affected (1.85 sec)
( s/ g, t0 \  O4 D1 d! c0 Y  tRecords: 0  Duplicates: 0  Warnings: 07 C9 g2 e" H; N# h
+ f+ e9 i$ A% V7 ?  a
mysql> load data infile '/etc/passwd' into table gz.six fields terminated by ':' lines terminated by '\n';
+ I& V' a0 z2 B6 P$ u7 L  bQuery OK, 24 rows affected (0.29 sec)' Z9 y8 \, Y( y9 M2 C  b! t
Records: 24  Deleted: 0  Skipped: 0  Warnings: 0
9 l* w" r! _- s% L7 E  T. ]
 楼主| 发表于 2020-6-17 17:59:40 | 显示全部楼层
为了避免类似问题再次发生,可以使用定义参数限制条件大一点。
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 13:45 , Processed in 0.045385 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

快速回复 返回顶部 返回列表