Mysql "Information Packet too large" solution

Source: Internet
Author: User
Tags mysql client mysql in

A communication packet is a single SQL statement sent to a MySQL server, or a single line sent to the client.

The maximum possible packet of information between the MySQL 5.1 server and the client is 1GB.

When a MySQL client or mysqld server receives a packet larger than max_allowed_packet byte, it emits a "packet too large" error and closes the connection. For some clients, if the communication packet is too large, a "lost connection to the MySQL server" error can be encountered during query execution.

Both the client and the server have their own max_allowed_packet variables, so if you plan to handle large packets, you must increase the variables on both the client and the server.

If you are using the MySQL client program, the default value for the Max_allowed_packet variable is 16MB. To set a larger value, you can start MySQL in the following ways:

mysql> mysql --max_allowed_packet=32M

It sets the packet size to 32MB.

The default Max_allowed_packet value for the server is 1MB. If the server needs to process large queries, you can increase the value (for example, if you are preparing to handle large BLOB columns). For example, to set this to 16MB, you can start the server in the following ways:

mysql> mysqld --max_allowed_packet=16M

You can also use the option file to set the Max_allowed_packet. To set this variable to 16MB for the server, you can add the following line to the options file:

[mysqld]
max_allowed_packet=16M

Increasing the value of this variable is safe because additional memory is allocated only when needed. For example, mysqld allocates more memory only if you issue a long query or mysqld must return a large result row. The variable's smaller default value is a precaution to capture the error packets between the client and the server, and to ensure that there is no memory overflow caused by accidental use of large packets.

If you are using a large BLOB value and do not grant mysqld access to enough memory to process the query, you may also experience strange problems with large packets. If this situation is suspected, try adding ulimit-d 256000 to the Mysqld_safe script and restart mysqld.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.