remember that your MySQL "max_allowed_packet" configuration setting (default 1MB)
mysql 默认最大能够处理的是1MB
如果你在sql使用了大的text或者BLOB数据,就会出现这个问题。
php手册上的注释
When trying to INSERT or UPDATE and trying to put a large amount of text or data (blob) into a mysql table you might run into problems.
In mysql.err you might see:
Packet too large (73904)
To fix you just have to start up mysql with the option -O max_allowed_packet=maxsize
You would just replace maxsize with the max size you want to insert, the default is 65536
mysql手册上说
Both the client and the server have their own max_allowed_packet
variable, so if you want to handle big packets, you must increase this variable both in the client and in the server.
If you are using the mysql client program, its default max_allowed_packet
variable is 16MB. To set a larger value, start mysql like this:
shell> mysql --max_allowed_packet=32M
That sets the packet size to 32MB.
The server’s default max_allowed_packet
value is 1MB. You can increase this if the server needs to handle big queries (for example, if you are working with big BLOB
columns). For example, to set the variable to 16MB, start the server like this:
shell> mysqld --max_allowed_packet=16M
You can also use an option file to set max_allowed_packet
. For example, to set the size for the server to 16MB, add the following lines in an option file:
[mysqld]
max_allowed_packet=16M