Sqlog recovery database error solution [error code: 2006 – MySQL server has gone away]

 

SQLyog is reporting an error when importing the database

Error Code: 2006 – MySQL server has gone away

The max_allowed_packet (a MySQL parameter) is not set to a large enough value.

Then I’ll change it.

In Windows:

In the MySQL server installation directory,
in my.ini file, add the following line under [mysqld] in SERVER SECTION.

max_allowed_packet = 16M

In Linux:

Copy the my-xxx.cnf file from /usr/share/mysql to /etc as my.cnf

xxx can be small, medium, large, huge … depending on the requirement.

$ cp /usr/share/mysql/my-xxx.cnf /etc/my.cnf

In the my.cnf file, change the default
max_allowed_packet = 1M
to
max_allowed_packet = 16M

Save the file and restart MySQL server.

Today, when importing .sql files, I got Error Code: 2006 – MySQL server has gone away error, it turns out that the imported sql file is larger than the default max_allowed_packet value of the system. I found the my.cfg file and modified other files, so I used the sql statement to modify it directly.

SET GLOBAL max_allowed_packet=67108864;

This is quite good, no need to restart the service after the change, it works directly

Similar Posts: