General error:2006 MySQL server has gone away

Source: Internet
Author: User

The experience of my own people

First of all, a brief introduction of this novice card entry backstage, this backstage is provided to the product personnel to use. Can be to a certain game of a specific section of the batch input card information to facilitate the player to obtain. Background set a one-time maximum input amount of 500.

Read the log first, the content of the error and log the same:

ERROR:SQLSTATE[HY000]: General error:2006 MySQL Server has gone away


This error message is well described as a result of a database timeout. Before listening to predecessors said, should be wait_timeout environment variable set up a problem. But after viewing, found Wait_timeout set high Ah, for 28800, should not be a problem ah. No solution.

When the head comes back, tell. The head laughs but the language, lets me only look, does not say the words.

The code is as follows Copy Code


Show global variables;

Set global wait_timeout = 120;


summed up the solution, but a lot of MySQL server has gone away is not related to this problem, there are and max_allowed_packet about the

SQLyog the error when importing the database

Error Code:2006–mysql server has gone away

Searched, said to be Max_allowed_packet (one of the parameters of MySQL) Set the value is not big enough.

I'll just change it, hehe.

In Windows:

In the MySQL Server installation directory,
In My.ini file, add the following line under [mysqld] into SERVER section.

Max_allowed_packet = 16M

In Linux:

Copy the my-xxx.cnf file From/usr/share/mysql to/etc as My.cnf

XXX can be small, medium, large, huge ... depending on the requirement.

The code is as follows Copy Code

$ cp/usr/share/mysql/my-xxx.cnf/etc/my.cnf

In the my.cnf file, change the default
Max_allowed_packet = 1M
To
Max_allowed_packet = 16M

Save the file and restart MySQL server.

Error Code:2006–mysql server has gone away errors when importing. sql files today, the imported SQL file is larger than the system default Max_allowed_packet value, and many modifications to the configuration file are found However, the My.cfg file is not found and the other files are not used, so the SQL statement is used directly to modify:

The code is as follows Copy Code

SET GLOBAL max_allowed_packet=67108864;

On it, not max_allowed_packet the bigger the better oh, we can according to their own situation to set.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.