The max_allowed_packet
variable sets the maximum size of a single query packet that MySQL can process.
If you encounter "Packet too large" errors, increasing max_allowed_packet
may help resolve the issue.
Ensure you set this value appropriately based on workload requirements. Setting it too high can lead to excessive memory usage.
The default value for this setting is 64MB in MySQL 8.0. If you experience issues, try increasing it to 128MB or higher based on your needs.
max_allowed_packet
setting:Create file:
/etc/mysql/conf.d/max_allowed_packet.cnf
with contents (e.g., increasing the default 64MB to 128MB):
[mysqld] max_allowed_packet = 128M
You can run the following command as "root" to create the configuration file shown above:
echo -e '[mysqld]\n''max_allowed_packet = 128M' > /etc/mysql/conf.d/max_allowed_packet.cnf
Restart MySQL:
sudo service mysql restart
Check the new value of the variable with:
sudo mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"