MySQL server has gone away

Handling error 2006: MySQL server has gone away on a windows xampp installation.

Summary: xampp installation on Windows XP, error encountered by a PHP script while uploading large files to a mysql database server.

This is caused by a mysql max_allowed_packet setting, which by default is set to 1M.

You can confirm the setting by
  • checking the value in sql by issuing a show variables command, or
  • by checking the system variables in phpmyadmin.
To change the setting, you need to edit the my.cnf file in your c:\...\xampp\sql\bin directory and change the default value of 1M to something larger, for example 16M. NOTE: Change the directory path to its actual value.

You may see the file named simply as "my", and it may also look like a shortcut. In this case, you cannot click on the file icon to open it. Instead, go start --> run and issue the command: notepad.exe c:\...\xampp\mysql\bin\my.cnf. Again, change the directory path to its actual value.