gpt4 book ai didi

mysql - Grails、MySQL (MariaDB) - 尽管数据较少,但仍超出了 max_allowed_pa​​cket

转载 作者:行者123 更新时间:2023-11-28 23:38:38 25 4
gpt4 key购买 nike

目前我正在开发一个 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_pa​​cket 的一半时,为什么我会收到该错误消息?为什么查询的数据包明显变大了一倍?

有什么想法吗?

最佳答案

数据库报告的数据包大小不等于您对象中的数据大小。由于双字节字符编码(大小可能相差 100%)和一些开销(考虑字符编码后大小最多相差 10%),可能存在显着差异。

关于mysql - Grails、MySQL (MariaDB) - 尽管数据较少,但仍超出了 max_allowed_pa​​cket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35017588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com