Error "MySQL server has gone away": How to fix the error message
The MySQL Error 2006 "MySQL server has gone away" occurs again and again - especially when importing databases into MySQL. There is a simple solution to the error. You can find an overview of all the steps here.
Just fix MySQL Error 2006 "MySQL server has gone away"
This MySQL error occurs when importing databases that are either too large or the connection is too slow for the upload. To fix the error, just change two variables in the MySQL configuration file.
- Under XAMPP in Windows you will find the configuration file in C: \ xampp \ mysql \ bin \ my.cnf by default
- If this file does not exist, you can simply use a
Right click> "New"> Create "Text Document". - Another practical tip will tell you how to save the file with a new file extension (.cnf).
- On Linux, this file is located at /etc/mysql/my.cnf by default
In this file you now enter higher values for the following variables:
- wait_timeout = 60 Here you enter the desired timeout in seconds - if it is still too low, you can simply increase it further.
- max_allowed_packet = 100M This variable determines the maximum package size of the upload.
Now set the value of this variable upwards so that it is larger than the file size of the database to be imported. - Finally restart MySQL - the error should no longer occur
- Important: on live systems, you should reset changed variables to their default values afterwards, as these could possibly represent a security hole for attackers.
In the next article we will show you how importing databases into MySQL using the phpMyAdmin tool works.