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:
- MySQL external import data error [How to Solve]
- Navicat Import Datas Error: — 1153 – Got a packet bigger than ‘max_allowed_packet’ bytes
- Error Code: 2006 – MySQL server has gone away
- Error while sending query packet in PHP runtime
- [Solved] MYSQL:1153 Got a packet bigger than ‘max_allowed_packet’ bytes
- [Solved] MYSQL:1153 Got a packet bigger than ‘max_allowed_packet’ bytes
- ERROR 2006 (HY000): MySQL server has gone away No
- MySQL reports an error using load data local infile
- [Solved] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=20131)
- Mysql import Error Code: 2013 – Lost connection to MySQL server during query