What does it mean?
MySQL is a program that stores the data of your website in a database. A database is like a big digital filing cabinet. MySQL receives data in small bundles called packets. The setting max_allowed_packet is the largest bundle it will accept. If a bundle is bigger, you see the error.
It often happens when you import a big database file or save a large post with images inside.
Option 1: Change it for now (needs root or admin rights)
This guide needs access to a MySQL account that has admin rights. This is normal on a VPS or dedicated server. On shared hosting you cannot do this. Use Option 3 instead.
- Connect to your server with SSH.
- Log in to MySQL:
mysql -u root -p
This opens the MySQL command line and asks for the password.
- Set a larger value. This example uses 64 MB:
SET GLOBAL max_allowed_packet=67108864;
This raises the limit until MySQL restarts.
- Check the value:
SHOW VARIABLES LIKE 'max_allowed_packet';
This prints the current limit.
Option 2: Make the change permanent
- Back up your config file first.
- Open the MySQL config file. It is often
/etc/my.cnfor/etc/mysql/my.cnf. - Find the
[mysqld]section. - Add this line:
max_allowed_packet=64M
- Save the file.
- Restart MySQL. On many systems the command is:
systemctl restart mysqld
On some systems the service is called mysql instead.
Option 3: Shared hosting
You cannot edit server settings on shared hosting. Try these instead:
- Split a big import file into smaller parts.
- Export your database again with the option for smaller inserts.
- Ask Hostvento support to raise the limit. Open a support ticket.
Quick recap
- The error means one bundle of data is larger than MySQL allows.
- Raise
max_allowed_packetwith SET GLOBAL or in the config file. - Restart MySQL after editing the file.
- On shared hosting, split the file or ask support.