如何更改max_allowed_packet大小 [英] How to change max_allowed_packet size
问题描述
我的MySQL数据库中的BLOB字段有问题-上传大于1MB的文件时出现错误Packets larger than max_allowed_packet are not allowed.
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大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!