{"id":1012,"date":"2013-11-21T13:42:49","date_gmt":"2013-11-21T20:42:49","guid":{"rendered":"http:\/\/jim-zimmerman.com\/?p=1012"},"modified":"2013-11-21T13:42:49","modified_gmt":"2013-11-21T20:42:49","slug":"mysql-error-2006-server-has-gone-away-while-restoring","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1012","title":{"rendered":"MySQL ERROR 2006 &#8211; server has gone away while restoring."},"content":{"rendered":"<p>I was getting the following errors when I was trying to restore a Request Tracker MySQL database in linux (Ubuntu to CentOS).<\/p>\n<blockquote><p>ERROR 2006 (HY000): MySQL server has gone away<br \/>\nNo connection. Trying to reconnect&#8230;<br \/>\nConnection id:    10<br \/>\nCurrent database: rt4<\/p>\n<p>ERROR 2006 (HY000): MySQL server has gone away<br \/>\nNo connection. Trying to reconnect&#8230;<br \/>\nConnection id:    11<br \/>\nCurrent database: rt4<\/p>\n<p>ERROR 2006 (HY000): MySQL server has gone away<br \/>\nERROR 2006 (HY000): MySQL server has gone away<br \/>\nNo connection. Trying to reconnect&#8230;<br \/>\nConnection id:    12<br \/>\nCurrent database: rt4<\/p><\/blockquote>\n<p>These errors came later in the restore:<\/p>\n<blockquote><p>ERROR 1231 (42000): Variable &#8216;time_zone&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;<br \/>\nERROR 1231 (42000): Variable &#8216;sql_mode&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;<br \/>\nERROR 1231 (42000): Variable &#8216;foreign_key_checks&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;<br \/>\nERROR 1231 (42000): Variable &#8216;unique_checks&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;<br \/>\nERROR 1231 (42000): Variable &#8216;character_set_client&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<\/p>\n<p>ERROR 1231 (42000): Variable &#8216;collation_connection&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;<br \/>\nERROR 1231 (42000): Variable &#8216;sql_notes&#8217; can&#8217;t be set to the value of &#8216;NULL&#8217;\n<\/p><\/blockquote>\n<p>To get the database restored, I had to change the maximum allowed packet setting.<\/p>\n<p>The best way to do that is to add the following line to the [mysqld] section of the my.cnf (CentOS: \/etc\/my.cnf or Ubuntu: \/etc\/mysql\/my.cnf):<\/p>\n<blockquote><p>max_allowed_packet = 16M<\/p><\/blockquote>\n<p>Then, restart your MySQL service.<br \/>\nUbuntu: service mysql restart<br \/>\nCentOS: service mysqld restart<\/p>\n<p>Now, I did this on both of my servers, then I could use my regular backup script and the setting would be picked up by the my.cnf.  However, you can do the backup with option enabled if it is not in your my.cnf by using something like the following:<\/p>\n<blockquote><p>mysqldump $thedb &#8211;user=&#8221;myid&#8221; &#8211;password=&#8221;$SQLPWD&#8221; &#8211;max_allowed_packet=16M > $thedb.sql<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I was getting the following errors when I was trying to restore a Request Tracker MySQL database in linux (Ubuntu to CentOS). ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect&#8230; Connection id: 10 Current database: rt4 ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect&#8230; Connection [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[343,342,340,341,248,98],"class_list":["post-1012","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-343","tag-342","tag-backup","tag-error","tag-mysql","tag-restore"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1012"}],"version-history":[{"count":1,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1012\/revisions"}],"predecessor-version":[{"id":1013,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1012\/revisions\/1013"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}