Sunday, 18 July 2021

ERROR: SQLSTATE[08S01]: Communication link failure: Got a packet bigger than 'max_allowed_packet' bytes


Reason:
When we use to import bigger size MySQL files then we get such an error.


Possible Solutions:

Please open your mysql terminal and type mysql to get a mysql prompt. In your mysql settings look for the following files.
  1. my.cnf 
  2. my.ini 
Open the above files and update

max_allowed_packet=100M
max_allowed_packet=1000M ; 1GB

After updating the above file in localhost or live server. Please restart the mysql/apache servers. So
that change will reflect. To restart the mysql server please run the following command.

service mysql restart

or you can open up your MySQL console and run the following command

set global max_allowed_packet=1000000000;
set global net_buffer_length=1000000;

The above commands basically, increase and set the max allowed packet size in mysql.

Note:
The default MySQL 5.6. 6 max packet size is 4MB
Also, you can dump the  MySQL file using the below command by mentioning the size
mysql --max_allowed_packet=100M -u root -p database < dump.sql

No comments:

Post a Comment

Laravel csrf token mismatch for ajax post request

Error "CSRF Token Mismatch" commonly occurs if tokens do not match in both sessions and sent , and received requests.CSRF token he...