In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you what the reasons for MySQL Server has gone away error are, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Background
Usually communicate with developers, or in the forum to answer questions, found that this question is asked very frequently, for example: what does it mean to report an error "MySQL server has gone away" in the program? How to avoid it? Therefore, it feels necessary to summarize the causes of this problem.
I happened to see a good summary of a foreign language blog, so I translated it and shared it with you.
Reason one: MySQL service is down.
The way to determine whether it belongs to this reason is simple, execute the following command to see how long mysql has been running:
$mysql-uroot-p-e "show global status like 'uptime';" +-+-+ | Variable_name | Value | +-+-+ | Uptime | 68928 | +-+-+ 1 row in set (0.04 sec)
Or check the error log of MySQL to see if there is a restart message:
$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 floor; port: 3306 130101 22:22:30 [Note] -' 127.0.0.1 'resolves to' 127.0.0.1 floor; 130101 22:22:30 [Note] Server socket created on IP: '127.0.0.1 floor. 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 high, the MySQL service has been running for a long time, indicating that the service has not been restarted recently. If there is no relevant information in the log, which means that the MySQL service has not been restarted recently, you can continue to check the following.
Reason 2: connection timeout
This is more likely if the program uses a long connection. That is, a persistent connection has not initiated a new request for a long time, reached the time out on the server side, and was forcibly closed by server. After that, when you initiate a query through this client, you will get an error server has gone away.
$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 secondsmysql > 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 (sec)
Reason 3: the process is actively kill on the server side
This reason is similar to the second reason, except that the initiator is DBA, or other job, and it is found that it is caused by long slow query execution of kill xxx.
$mysql-uroot-p-e "show global status like 'com_kill'" +-+-+ | Variable_name | Value | +-+-+ | Com_kill | 0 | +-+-+
Reason 4: Your SQL statement was too large
This kind of error will also occur when the result set of the query exceeds max_allowed_packet, and the location method is to type out the relevant error statement. Export to a file as select*into outfile to see if the file size exceeds max_allowed_packet. If so, 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) what are the reasons for the MySQL Server has gone away error report? Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.