Fix MySQL Got a Packet bigger than “max_allowed _packet” bytes Error.

Spread the love

Sometimes you might notice that when you are doing MySQL things on your remote server/local server Or else when you doing unit tests withs PHP you are getting this error Says,

Fix MySQL Got a Packet bigger than "max_allowed _packet" bytes Error

Got a Packet bigger than “max_allowed_packet” bytes.

This is because of transferring payload size that is greater than allowed packet size in MySQL.So we can fix this easily.

First Method

All you have to do is increase the max_allowed_packet size from the MySQL configuration file.

How to find the configuration file.

  • /etc/my.cnf
  • /etc/mysql/my.cnf
  • $MYSQL_HOME/my.cnf
  • [datadir]/my.cnf
  • ~/.my.cnf

Just add “max_allowed_packet=500M” or whatever size that your server can handle. Save the file and restart the MySQL server and You are done.

Second Method

The second method is also simple. All you have to do is increase packet size using MySQL CLI. These sets of commands will increase your max_allowed_packet size in MySQL.

Fix MySQL Got a Packet bigger than "max_allowed _packet" bytes issue

SELECT CONNECTION_ID();

select @max_allowed_packet;

select @@global.max_allowed_packet;

SET GLOBAL max_allowed_packet=10737418224;

select @max_allowed_packet;

select @@global.max_allowed_packet;

These commands will increase your MySql Memory and fix your MySQL Got a Packet bigger than “max_allowed _packet” bytes Error.

Hi, I'm a software engineer from Sri Lanka who has knowledge in programming languages like Dart | PHP | Javascript |C# |Java, etc. Currently studying Computer Science at University College Coventry , London.

Leave a Reply

Your email address will not be published. Required fields are marked *