Solution to MySQL error #2006 in XAMPP

I recently ran into the MySQL error #2006 when importing a MySQL database into XAMPP for testing locally.

Error 2006: MySQL Server has gone away.

My research led me to understand this error occurs when your MySQL connection times out while waiting for a response.

After a few Google queries I found the solution for my MySQL error #2006 to be in editing the my.ini for MySQL in XAMPP.

Steps for MySQL error 2006 solution:

  • Edit the “my.ini” file found at “:\xampp\mysql\bin\”.
  • In the my.ini file, edit the “max_allowed_packet” by increasing the value.
    • XAMPP default value is 1M. I updated it to 10M.
  • Save the my.ini file.
  • Restart your MySQL and Apache server in XAMPP.

This solution worked for me. Hopefully it may helped another soul stumped by a pesky 2006 MySQL error code in their local XAMPP environment.