MySQL server has gone away

Source: Internet
Author: User

MySQL server has gone away

The most common cause of gone away errors for MySQL server has is that the server timed out and closed the connection. By default, if nothing happens, the server closes the connection after 8 hours. You can change the time limit by setting the Wait_timeout variable when starting mysqld.
Troubleshoot MySQL server has gone away

1, applications (such as PHP) for a long time to execute the batch of MySQL statements. The most common is acquisition or new and old data conversion.

Solution:

Add or modify the following two variables in the my.cnf file:

wait_timeout=2880000
Interactive_timeout = 2880000
A specific description of two variables can be Google or read the Official Handbook. If you cannot modify MY.CNF, you can set up client_interactive when you connect to the database, for example:

sql = "Set interactive_timeout=24*3600";
Mysql_real_query (...)

2, execute a SQL, but the SQL statement is too large or the statement contains a BLOB or Longblob field. For example, the processing of image data

Solution:

Add or modify the following variables in the my.cnf file:

Max_allowed_packet = 10M
(You can also set the size you want)

Max_allowed_packet


The "MySQL (best combination of PHP) server has gone away" error occurs when you import a backup using MySQL (the best combination of PHP), possibly because some of the INSERT statements are larger than the MySQL ( The best combination of PHP with the size of the buffer currently set.

Solutions

1. When using phpMyAdmin to back up MySQL (the best combination of PHP), select only

Data:
Full insert
Extended Insert

Expand insert do not tick

2. Use MySQL (best combination of PHP) dump backup without adding--opt

This will only generate a complete INSERT statement, and there will be no error during import.

3. Modify My.ini

Open My.ini and find the [MySQL (best combination of PHP) d] line, add the following

[The best combination of MySQL (and PHP) d]

#扩大缓冲区
max_allowed_packet=32m
After saving, restart MySQL (the best combination with PHP)

MySQL Server not available

Workaround:

1, the virtual host users please contact the space provider to confirm whether the MySQL server is normal, or your program in the running process consumes too much server resources, please contact the space provider to confirm;

2, independent host users please optimize your MySQL configuration, check the operation of MySQL, the appropriate time to increase the configuration of the server.

3, because the execution of excessive, resulting in MySQL connection timeout, if it is a stand-alone host please modify the mysql  configuration file wait_timeout This value set a little larger.

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.