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.

  • Viper Romay

    thanks! Really helpful πŸ™‚

  • Amol Bhavsar

    Thanks for such an information, it worked for me.

  • Amit katwal

    Thanks brother

  • IR

    Thanks πŸ™‚

  • Thore

    Thanks for your advice.
    In older Versions the file is named “my” without .ini. You have to drag and drop the file into a open notepad, where you can edit the values.

  • Andy Gradel

    Thanks! Saved my night….

  • sujata

    BUT it didnt worked 4 me….i tried the same steps ….wat else can i try……????

    • Owning

      Besure you do it on both lines of max_allowed_packet there are 2 in my.ini
      i raised it to 10M still to small for some queries but for most of them it’s working fine

      • Thanks for that tip! I’ve been fighting this for quite some time…

      • ggbb.

        i its been years.. but really thanks man πŸ™‚

  • tomy

    it works, thank bro

  • Prasad

    Thank you very much…. Its working for me

  • dany

    Thank you!

  • Edkar Rodriguez

    great! thank you! since Mexico πŸ˜›

  • Maher B

    thanks, you saved me πŸ™‚

  • James Githinji

    Thank you very much Andrew. It has worked for me. God bless you

  • sabir ali

    thanks so much dear

  • fede

    works like a chair with me, thank you

  • NItesh

    thanks πŸ™‚

  • Rodolfo Ferro Casagrande

    You are my hero

  • fxkmilo22

    Gracias!!! Soluciono el problema q tenia

  • Edison

    Gracias brother muy util el consejo πŸ˜€ (thanks for the advise)

    Dios te bendiga (Y)

  • Galdo

    Thanks men πŸ˜‰

  • bearzn

    Thanks man… I had to increase to 128mb for both limits (because of heavy quiry)… worked!

    • eppand

      Good news! Glad it helped.

  • Arturo

    Where do I find this?: :xamppmysqlbin

  • Adriano Ruseler

    Wow, happy new year!
    Thanks for the help!

    • eppand

      Glad it was helpful!

  • Francis

    thanks for that info

  • Invited

    thanks, you helped me πŸ˜€

  • arun

    Thanks for your advice, its working like a charm.

  • nghia nguyen van

    thank for you!:)

  • Reynier

    yes! thank you so much! its work

  • Thank you. It works.

  • Owais

    I am getting this error can u plzz help me out

  • Fito

    All is ok! Thank you!

  • Alauddin Al-Amin

    i am pleased and blessed with your solution … thanks a lot friend . πŸ™‚

  • Helped, thx !

  • Barak Danin

    Thanks! Worked like a charm

  • Pingback: Error Code: 2006 – MySQL server has gone away when importing backup | Blog

  • Ashish Ranjan

    Thanks a lot …….. now works fine

  • mechanic

    Thank you.

  • sandy

    Its not working for me

  • IlΓ‘n

    Thanks a lot! Worked fo me!

  • James

    But mine is already set to 1 billion:
    and I still get the error. OK, I guess I’ll try 1 trillion:

  • thanks!

  • boiporitto

    Thanks a lot, it worked for me.

  • Awesome! Thank you! Solved my problem even after so many years since posting this! πŸ™‚

  • faith

    mine didnt work