MySQL Error 1153 – Got a packet bigger than ‘max_allowed_packet’ bytes

When we trying to import a large SQL backup some times we get below error.

“Got a packet bigger than ‘max_allowed_packet’ bytes”

The fix is to increase the MySQL daemon’s max_allowed_packet. You can do this to a running daemon by logging in as Super and running the following commands. Keeping the session open create a 2nd session in which to run the import.

The mysql root username is `admin` and the password is the cpanel/plesk password.

# mysql -u admin -p

mysql> set global net_buffer_length=1000000;
Query OK, 0 rows affected (0.00 sec)

mysql> set global max_allowed_packet=1000000000;
Query OK, 0 rows affected (0.00 sec)

We can also permanently increase the packet size. We need to edit the MySQL configuration by default it is /etc/my.cnf .  We can set the desired value as you see in the below snippet.

[mysqld]
# ...
# There might be other config parameters in here
# ...
max_allowed_packet = 256M

Once the configuration changes applied, we need to restart the MySQL server. Hence the value will get updated.

Use the below command to see the updated value.

MariaDB [(none)]> SELECT @@max_allowed_packet / 1024 / 1024;
+------------------------------------+
| @@max_allowed_packet / 1024 / 1024 |
+------------------------------------+
| 256.00000000 |
+------------------------------------+
1 row in set (0.00 sec)