How to change max_allowed_packet size(如何更改 max_allowed_packet 大小)
问题描述
我的 MySQL 数据库中的 BLOB 字段有问题 - 当上传大于约 1MB 的文件时,我收到一个错误 不允许大于 max_allowed_packet 的数据包.
I am having a problem with BLOB fields in my MySQL database - when uploading files larger than approx 1MB I get an error Packets larger than max_allowed_packet are not allowed.
这是我尝试过的:
在 MySQL 查询浏览器中,我运行了一个 show variables like 'max_allowed_packet'
这给了我 1048576.
In MySQL Query Browser I ran a show variables like 'max_allowed_packet'
which gave me 1048576.
然后我执行查询 set global max_allowed_packet=33554432
后跟 show variables like 'max_allowed_packet'
- 它按预期给了我 33554432.
Then I execute the query set global max_allowed_packet=33554432
followed by show variables like 'max_allowed_packet'
- it gives me 33554432 as expected.
但是当我重新启动 MySQL 服务器时,它神奇地回到了 1048576.我在这里做错了什么?
But when I restart the MySQL server it magically goes back to 1048576. What am I doing wrong here?
额外的问题,是否可以压缩 BLOB 字段?
Bonus question, is it possible to compress a BLOB field?
推荐答案
在 my.ini
或 ~/.my.cnf
文件中更改,包括单行在文件中的 [mysqld]
或 [client]
部分下:
Change in the my.ini
or ~/.my.cnf
file by including the single line under [mysqld]
or [client]
section in your file:
max_allowed_packet=500M
然后重启 MySQL 服务就大功告成了.
then restart the MySQL service and you are done.
有关详细信息,请参阅文档.
See the documentation for further information.
这篇关于如何更改 max_allowed_packet 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更改 max_allowed_packet 大小


- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01