問題描述
我的 MySQL 數(shù)據(jù)庫中的 BLOB 字段有問題 - 當(dāng)上傳大于約 1MB 的文件時(shí),我收到一個(gè)錯(cuò)誤 不允許大于 max_allowed_pa??cket 的數(shù)據(jù)包.
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 查詢?yōu)g覽器中,我運(yùn)行了一個(gè) show variables like 'max_allowed_pa??cket'
這給了我 1048576.
In MySQL Query Browser I ran a show variables like 'max_allowed_packet'
which gave me 1048576.
然后我執(zhí)行查詢 set global max_allowed_pa??cket=33554432
后跟 show variables like 'max_allowed_pa??cket'
- 它按預(yù)期給了我 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.
但是當(dāng)我重新啟動(dòng) MySQL 服務(wù)器時(shí),它神奇地回到了 1048576.我在這里做錯(cuò)了什么?
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 服務(wù)就大功告成了.
then restart the MySQL service and you are done.
有關(guān)詳細(xì)信息,請參閱文檔.
See the documentation for further information.
這篇關(guān)于如何更改 max_allowed_pa??cket 大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!