今天在用mysql开发项目的时候,用BLOB字段存储文件二进制流。
一、先是报异常
com.mysql.jdbc.MysqlDataTruncation:
Data truncation: Data too long for column 'title' at row 1
发现上传的文件大于65535字符(mysql在UTF-8编码下汉字也是一个字符,跟oracle一个汉字3个字符不一样)
用show full fields from table_name; 查询的collation字段可以看到当前表的字符集。
一个BLOB或TEXT列,最大长度为65535(2^16-1)个字符。(0.06 M兆)
MEDIUMBLOB
MEDIUMTEXT
一个BLOB或TEXT列,最大长度为16777215(2^24-1)个字符。 (16M)
LONGBLOB
LONGTEXT
一个BLOB或TEXT列,最大长度为4294967295(2^32-1)个字符。(4G)
最后修改为LONGBLOB 解决第一个问题。
二、max_allowed_packet设置及问题
报的异常:com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1521830 > 1048576). You can change this value on the server
by setting the max_allowed_packet' variable
mysql根据配置文件会限制server接受的数据包大小。
有时候大的插入和更新会被max_allowed_packet 参数限制掉,导致失败。
根据show VARIABLES like '%max_allowed_packet%'; 查询value值(字节)
解决方法,在my.ini里的[mysqld]增加如下部分
[mysqld]
max_allowed_packet=64M
注意,在[client]和[mysql]部分增加无效,那个是客户端读取的参数。
然后一定记住重启MYSQL服务(不是终端),使用net stop mysql + net start mysql 或者 cmd->services.msc重启MYSQL服务,这里仅限于Windows
分享到:
相关推荐
博文链接:https://zyx19920203.iteye.com/blog/2301226
今天在往mysql中插入数据时遇到的问题,翻译过来的意思是:查询数据包太大 建议修改max_allowed_packet参数值。 针对我执行的插入操作来说,意味着一次性执行的sql语句太大,超过了mysql默认设置的值(我用的是...
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1354 > 1024). You can change this value on the server by setting the max_allowed_packet’ variable MySQL根据配置...
想改变这个问题,需要注意几点: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (2054817 > 1048576). You can change this value on the server by setting the max_allowed_packet’ ...
com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4232009 > 4194304). You can change this value on the server by setting the max_allowed_packet’ variable. 出现上面的错误是因为...
4.7.1: Packet Tracer 综合技巧练习
MySQL批量插入问题 ...nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (5677854 > 1048576). You can change this value on the server by setting the max_allowed_pac
2.9.1:Packet_Tracer_综合技巧练习 (1).pdf
11.7.1Packet Tracer 综合技能练习啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
10.3.1.2 Packet Tracer - Skills Integration Challenge(1).pka
In addition, the book covers additional topics for memory management and congestion avoidance, used to extract higher performance from the interconnection network. Table of Contents Part I: ...
IseHarvest is a network analysis tool designed as a framework for extracting data from TCP streams. Once extracted, it reconstructs the data into individual files and documents from captured network ...
当日志中出现了诸如:“Package for query is too large (xxxxxxxx > 4194304). You can change this value on the server by setting the max_allowed_package variable”的提示的时候,错误的本身就清楚的提示了...
packet tracer实验集合(一共84个,附加答案).rar
The Practical Packet Analysis course is perfect for beginners to intermediate analysts, but seasoned pros will probably learn a few useful techniques too. Whether you’ve never capture packets before ...
思科 路由模拟 Packet Tracer 5.2 共5个分卷...
PACKET 保证完整版 MySQL for Python Integrate the flexibility of Python and the power of MySQL to boost the productivity of your applications Albert Lukaszewski, PhD Table of Contents Chapter 1: ...
mysql5.7 修改max_allowed_packet方法
Focusing on intra-domain dynamic routing protocols this book provides an in-depth understanding of IP routing and forwarding technologies, and their implementation within Cisco routers.