Linux : Exceeds max allowed packet for MySQL or Got an error reading communication packets

By | October 27, 2024

Got the following entry in your mysqld.log or mariadb.log?

[Warning] Aborted connection 154669 to db: ‘db_name’ user: ‘db_user’ host: ‘hostname’ (Got an error reading communication packets)

This is usually related to the “max_allowed_packet” parameter.  Try increasing the value and see if it persist.

1. Check current parameter for max_allowed_packet:

show variables like 'max_allowed_packet';

Output will look like this :

mysql> show variables like 'max_allowed_packet';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+
1 row in set (0.00 sec)

2. Set a higher value for max_allowed_packet :

With MySQL client :

SET GLOBAL max_allowed_packet=268435456;

Or directly from the shell :

mysqld --max_allowed_packet=256M

If satisfied with the result, apply to the server config file as followed so it will survive service restart :

[mysqld]
...
max_allowed_packet = 256M
...