"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Solve MySQL error 1153: Packet exceeds 'max_allowed_packet' limit

Solve MySQL error 1153: Packet exceeds 'max_allowed_packet' limit

Posted on 2025-04-18
Browse:102

How to Solve MySQL Error 1153:

MySQL Error 1153: Troubleshooting Got a Packet Bigger Than 'max_allowed_packet' Bytes

Facing the enigmatic MySQL Error 1153 while importing a database dump? Let's delve into the culprit and explore solutions to rectify this issue.

Understanding the Error

This error indicates that a packet received during the import process exceeds the 'max_allowed_packet' size limit set on either the client or the server. In your case, it suggests the presence of large attachments that trigger substantial inserts.

Resolving the Error

To resolve this problem, you need to modify both the client and server settings to accommodate larger packet sizes.

Client-Side Modification:

Adjust the 'max_allowed_packet' size for the client using the command line:

mysql --max_allowed_packet=32M -u root -p database 

Server-Side Modification:

  1. Editing Configuration File:

    • Locate the MySQL configuration file (e.g., my.cnf or my.ini, often found in /etc/mysql/).
    • Under the "mysqld" section, set 'max_allowed_packet=100M' to allow packets of size up to 100 megabytes.
  2. Using MySQL Commands:

    • Connect to the database using the MySQL console.
    • Execute the following commands to change the relevant settings:
    set global net_buffer_length=1000000;
    set global max_allowed_packet=1000000000;

Recommendations:

  • Use a sufficiently large value for 'max_allowed_packet' to prevent future issues.
  • Check if any other settings need adjustment, such as 'net_buffer_length,' which determines the maximum buffer size for network packets.
  • Consider using a data migration tool instead of direct dump imports for large databases to avoid this type of error.
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3