MySQL server has gone away

Source: Internet
Author: User

MySQL server has gone away
 
The most common cause of the MySQL server has gone away error is that the server times out and closes the connection. By default, if nothing happens, the server closes the connection eight hours later. You can change the time limit by setting the wait_timeout variable when starting mysqld.
Solve MySQL server has gone away

1. applications (such as PHP) execute MYSQL statements in batches for a long time. The most common is collection or conversion of New and Old data.

Solution:

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

Wait_timeout = 2880000
Interactive_timeout = 2880000
For details about the two variables, refer to google or the official manual. If you cannot modify my. cnf, you can set CLIENT_INTERACTIVE when connecting to the database. For example:

SQL = "set interactive_timeout = 24*3600 ";
Mysql_real_query (...)

2. Execute an SQL statement, but the SQL statement is too large or the statement contains BLOB or longblob fields. For example, processing image data

Solution:

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

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

Max_allowed_packet


The "MySQL (best combination with PHP)" server has gone away "error occurs when you use the MySQL (best combination with PHP) command line to import the backup, this may be because the size of some insert statements exceeds the buffer size currently set by MySQL (the best combination with PHP.

Solution

1. When using phpmyadmin to back up MySQL (the best combination with PHP), select

Data:
Complete insert
Extended insert

Do not select extension insert

2. Do not add -- opt when using MySQL (the best combination with PHP) dump backup.

In this way, only the complete insert statement will be generated, and no errors will occur during the import.

3. modify my. ini

Open my. ini and find [MySQL (the best combination with PHP) d]. Add

[MySQL (the best combination with PHP) d]

# Expanding the Buffer Zone
Max_allowed_packet = 32 M
After saving, restart MySQL (the best combination with PHP)

MySQL Server unavailable

Solution:

1. If you are a VM user, contact the Space Provider to check whether the MySQL server is normal or if your program consumes too much server resources during running. Contact the space provider for confirmation;

2. for standalone host users, please optimize your MySQL configuration, check the running status of MySQL, and add the server configuration as appropriate.

3. the MySQL connection times out because of excessive execution actions. If it is an independent host, modify the value of wait_timeout In the MySQL configuration file to a larger value.

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.