MySQL server has gone away solution

Source: Internet
Author: User
Tags drupal

First make sure that your space quotient is not a problem, if you are virtual space, the following operations

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 too many, 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.

If you are your own server can operate as follows


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:

The code is as follows Copy Code
wait_timeout=2880000
Interactive_timeout = 2880000


A specific description of two variables can be Google or read the Official Handbook. If you cannot modify the MY.CNF, you can set it when you connect to the database

The code is as follows Copy Code
Client_interactive, 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:

The code is as follows Copy Code
Max_allowed_packet = 10M (You can also set the size you want)
The function of the Max_allowed_packet parameter is to control the maximum length of its communication buffer.


This can be mainly due to several reasons:
One possibility is that the SQL statement sent is too long to exceed the size of the max_allowed_packet, and if this is the reason, you just need to modify the MY.CNF to enlarge the Max_allowed_packet value.
There is also a possibility for some reason to timeout, such as the use of singleton in the process of getting a database connection, although the database is connected multiple times, but in fact, the same connection is used, and a two times in the program of the operation of the database Time exceeded wait_timeout (show Status to see this setting), there may be a problem. The simplest way is to change the wait_timeout, of course, you can also in the program occasionally mysql_ping (), so that MySQL knows it is not a person in the fight.
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:

The code is as follows Copy Code
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:

The code is as follows Copy Code

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:

The code is as follows Copy Code
Max_allowed_packet = 10M

(You can also set the size you want)

Max_allowed_packet
The function of a parameter is to control the maximum length of its communication buffer

MySQL: Spooky MySQL server has gone away and its resolution


Introduction
Here are a step by step guide, equally valid for your Linux server as as as the any local Windows MySQL installation The is using as a trial installation along with your local Drupal installation.

MySQL comes with a default configuration of the ' resources it is going to-use, specified in ' My.ini ' (Windows) or "my.cnf" (Linux) during the installation of MySQL. In the Windows this file are located by default at C:Program Filesmysqlmysql Server X.ymy.ini. In Linux This file are located at/etc/my.cnf to set global options, or/usr/local/var/mysql-data-dir/my.cnf to set server- Specific options.

Allowed by the default configuration are normally insufficient to run a resource-intensive application. Must modify the following resource specifications if they are available in your original file, or add th EM to the configuration file if they are is not already specified (because some are not present by default):

Important:remember to keep backup files before your do anything! You'll also have to reload the MySQL service after making changes to these configuration files.

MyISAM Specifications

[Mysqld]

The code is as follows Copy Code

Port = 3306
Socket =/tmp/mysql.sock
Skip-locking
Key_buffer = 384M
Max_allowed_packet = 64M
Table_cache = 4096
Sort_buffer_size = 2M
Read_buffer_size = 2M
Read_rnd_buffer_size = 64M
Myisam_sort_buffer_size = 64M
Thread_cache_size = 8
Query_cache_size = 32M
InnoDB Specifications

Innodb_buffer_pool_size = 384M
Innodb_additional_mem_pool_size = 20M
Innodb_log_file_size = 10M
Innodb_log_buffer_size = 64M
Innodb_flush_log_at_trx_commit = 1
Innodb_lock_wait_timeout = 180


Note:it is assumed this is the are using the InnoDB database tables, as Drupal is a resource intensive. If you are is not using the InnoDB database tables try to alter this, in view of the the fact so you are getting the Warning: MySQL server has gone away-apparently meaning that your the setup is resource intensive. Convert MyISAM Tables to InnoDB.


For further reference, MySQL server has gone away

Http://www.111cn.net/database/mysql/38459.htm

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.