Mysql PacketTooBigException Packet for query is too large
来源:互联网 发布:黑暗之魂2原罪学者优化 编辑:程序博客网 时间:2024/06/05 03:38
一、问题描述
今天编辑富文本内容提交更新到数据库时,遇到以下错误:
Error updating database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (23663004 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
编辑器用的是 vue-quill-editor,这个编辑器对图片的处理是把图片进行 Base64 编码到文本中。
以上的错误提示里,是说查询的数据包太大??
二、解决方案
以上错误提示也给出了方案,设置 Mysql 的 max_allowed_packet 就可以了。
在 my.cnf(Linux) 或 my.init(Windows) 文件的 [mysqld] 下方,增加一行设置:
[mysqld]max_allowed_packet=128M
这个值默认是 4M,最大可设置为 1G,设置时必须是 1024 的倍数,否则会被 rounded down 到最近的一个 1024 的倍数值。
然后重启 Mysql 即可:
# service mysql restart
Mysql 官方文档 说明:
The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function. The default is 4MB.
The packet message buffer is initialized to net_buffer_length bytes, but can grow up to max_allowed_packet bytes when needed. This value by default is small, to catch large (possibly incorrect) packets.
You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use. The protocol limit for max_allowed_packet is 1GB. The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple.
When you change the message buffer size by changing the value of the max_allowed_packet variable, you should also change the buffer size on the client side if your client program permits it. The default max_allowed_packet value built in to the client library is 1GB, but individual client programs might override this. For example, mysql and mysqldump have defaults of 16MB and 24MB, respectively. They also enable you to change the client-side value by setting max_allowed_packet on the command line or in an option file.
The session value of this variable is read only. The client can receive up to as many bytes as the session value. However, the server will not send to the client more bytes than the current global max_allowed_packet value. (The global value could be less than the session value if the global value is changed after the client connects.)
三、参考
- 《com.mysql.jdbc.PacketTooBigException》
- 《max_allowed_packet》
- PacketTooBigException: Packet for query is too large
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large
- Mysql PacketTooBigException Packet for query is too large
- nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1109 > 1024
- 解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large (3158064)问题
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large > 1024
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (2017898 > 1048576)
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4200044 > 1048576). You can cha
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (11707239 > 1048576). You can c
- Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (144900 > 1024)
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1157 > 1024).
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4232009 > 4194304).
- 解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large问题
- 解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large (3158064)问题
- 解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large (3158064)问题
- MYSQL Packet for query is too large
- MYSQL Packet for query is too large
- MySQL Packet for query is too large
- heredoc与nowdoc
- 滑雪(POJ-1088)
- 我的第一篇博客
- linux vim的配置
- UMR祝你元宵节快乐!(博弈论)
- Mysql PacketTooBigException Packet for query is too large
- [Leetcode] #85 Maximal Rectangle
- urllib/urllib2和BeautifulSoup爬虫学习
- 打印"*"等腰三角形
- 数据库优化之PreparedStatement
- 工具类
- 华为荣耀畅玩5C NEM-UL10 ROOT那些事儿(亲测成功)
- ASP.NET中树形图的实现
- UVA 7529 - DNA Sequencing