ERROR 2006 (HY000): MySQL server has gone away No

What are the eight life cycle hook functions of Vue>>>

My problem is parameter max_ allowed_ Packet = 4m is too small, which leads to the addition of Max in my.cnf_ allowed_ Packet = 16m restart MySQL server to take effect, and set MySQL > set global max_ allowed_ packet=1024*1024*16; Does not take effect after restart

(I forgot what happened at that time)

Message: http://ronaldbradford.com/blog/sqlstatehy000-general-error-2006-mysql-server-has-gone-away-2013-01-02/

Reason 1. MySQL service is down

The method to determine whether this is the reason is very simple. Execute the following command to check the running time of MySQL

$ mysql -uroot -p -e “show global status like ‘uptime’;” +—————+——-+ | Variable_ name | Value | +—————+——-+ | Uptime | 68928 | +—————+——-+ 1 row in set (0.04 sec)

Or check the MySQL error log to see if there is any restart information

$ tail /var/log/mysql/error.log 130101 22:22:30 InnoDB: Initializing buffer pool, size = 256.0M 130101 22:22:30 InnoDB: Completed initialization of buffer pool 130101 22:22:30 InnoDB: highest supported file format is Barracuda. 130101 22:22:30 InnoDB: 1.1.8 started; log sequence number 63444325509 130101 22:22:30 [Note] Server hostname (bind-address): ‘127.0.0.1’; port: 3306 130101 22:22:30 [Note] – ‘127.0.0.1’ resolves to ‘127.0.0.1’; 130101 22:22:30 [Note] Server socket created on IP: ‘127.0.0.1’. 130101 22:22:30 [Note] Event Scheduler: Loaded 0 events 130101 22:22:30 [Note] /usr/sbin/mysqld: ready for connections. Version: ‘5.5.28-cll’ socket: ‘/var/lib/mysql/mysql.sock’ port: 3306 MySQL Community Server (GPL)

If the uptime value is large, it indicates that the MySQL service has been running for a long time. This indicates that the service has not been restarted recently

If there is no relevant information in the log and the MySQL service of the table name has not been restarted recently, you can continue to check the following items

2. Connection timeout

If the program uses a long connection, this is more likely

That is to say, a long connection has not been initiated for a long time, reaching the timeout of the server, and is forced to close by the server

Later, when a query is initiated through this connection, an error server has gone away will be reported

$ mysql -uroot -p -e “show global variables like ‘%timeout’;” +—————————-+———-+ | Variable_ name | Value | +—————————-+———-+ | connect_ timeout | 30 | | delayed_ insert_ timeout | 300 | | innodb_ lock_ wait_ timeout | 50 | | innodb_ rollback_ on_ timeout | OFF | | interactive_ timeout | 28800 | | lock_ wait_ timeout | 31536000 | | net_ read_ timeout | 30 | | net_ write_ timeout | 60 | | slave_ net_ timeout | 3600 | | wait_ timeout | 28800 | +—————————-+———-+

mysql> SET SESSION wait_ timeout=5; ## Wait 10 seconds mysql> SELECT NOW(); ERROR 2006 (HY000): MySQL server has gone away No connection. Trying to reconnect… Connection id: 132361 Current database: *** NONE *** +———————+ | NOW() | +———————+ | 2013-01-02 11:31:15 | +———————+ 1 row in set (0.00 sec)

3. The process is actively killed on the server side

This is similar to case 2, except that the initiator is a DBA or other job. It was found that a long time of slow query execution resulted in killing XXX

$ mysql -uroot -p -e “show global status like ‘com_ kill'” +—————+——-+ | Variable_ name | Value | +—————+——-+ | Com_ kill | 0 | +—————+——-+

4. Your SQL statement was too large.

When the result set of the query exceeds max_ allowed_ This error will also appear in packet. The location method is to print out the relevant error statements

Use select * into outfile to export to the file and check whether the file size exceeds max_ allowed_ Packet. If it exceeds, you need to adjust the parameters or optimize the statement

mysql> show global variables like ‘max_ allowed_ packet’; +——————–+———+ | Variable_ name | Value | +——————–+———+ | max_ allowed_ packet | 1048576 | +——————–+———+ 1 row in set (0.00 sec)

Modify parameters:

mysql> set global max_ allowed_ packet=1024*1024*16; mysql> show global variables like ‘max_ allowed_ packet’; +——————–+———-+ | Variable_ name | Value | +——————–+———-+ | max_ allowed_ packet | 16777216 | +——————–+———-+ 1 row in set (0.00 sec)

Similar Posts: