Packet for query is too large error resolution in MySQL data

Source: Internet
Author: User

Sometimes, when a program connects to MySQL to perform an operational database, a similar error message appears:

Packet for query is too large (4230 > 1024). You can change this value on the server by setting the Max_allowed_packet ' variable.

The general reason for this error is: When sending a query command to the MySQL database, the default condition is that the size of a packet is 1024, the actual length of a statement is the size of this, so the execution of the statement error. The solution is to adjust the size of this parameter in MySQL.

Here's an example of a Linux service solution:

1. Confirm the MySQL installation directory and enter:
/home/apps/mysql-5.7.17-linux-glibc2.5-x86_64


2. Enter the bin directory under MySQL and execute the following command to enter the MySQL command line: (where root password is password)
./mysql-uroot-ppassword

3. Check the package size (MySQL command line execution):
Show variables like '%max_allowed_packet% ';

4. Set the package size (MySQL command line execution):
Set global max_allowed_packet = 100*1024;

5. Exit (execute on MySQL command line)
Quit

6. Stop the MySQL service:
./mysqladmin-uroot-ppassword shutdown

7. Start the service again:
./mysqld--user=mysql &

Packet for query is too large error resolution in MySQL data

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.