作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
目前我正在开发一个 grails 项目,因此我在本地使用 XAMPP 5.6.14。我现在遇到了以下问题:
Packet for query is too large (10485896 > 10485760). You can change this value on the server by setting the max_allowed_packet' variable.
在那个错误发生之前,我改变了 my.cnf 的配置如下:
[mysqld]
max_allowed_packet = 10M
innodb_buffer_pool_size = 400M
innodb_log_file_size = 100M
我想保存在数据库中的域类如下所示:
class DocumentFile {
Date dateCreated
Timestamp timestamp
Integer someValue
String someOtherValue
Blob file
static constraints = {
someValue nullable: true
someOtherValue nullable: true
}
static mapping = {
file type: 'blob'
}
}
出于测试原因,我使用以下行将新文件插入数据库:
def file = new javax.sql.rowset.serial.SerialBlob(file.getBytes())
sql.execute("insert into tblDocumentFile (dateCreated, timestamp, file, someOtherValue, someValue) values (NOW(), NOW(), ?, ?, ?)", [file, 'someValue', 1])
到目前为止一切顺利。问题是 - 当文件大小恰好为 5242880 字节时,会出现上面的错误消息。这就是我被困的地方。
当我的文件恰好是 max_allowed_packet
的一半时,为什么我会收到该错误消息?为什么查询的数据包明显变大了一倍?
有什么想法吗?
最佳答案
数据库报告的数据包大小不等于您对象中的数据大小。由于双字节字符编码(大小可能相差 100%)和一些开销(考虑字符编码后大小最多相差 10%),可能存在显着差异。
关于mysql - Grails、MySQL (MariaDB) - 尽管数据较少,但仍超出了 max_allowed_packet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35017588/
我是一名优秀的程序员,十分优秀!