mysqldump導出報錯"mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `file_storage` at row: 29"


今天mysql備份的crontab自動運行的時候,出現了報警,報警內容如下

mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `file_storage` at row: 29
mysqldump: Couldn't execute 'show table status like 'property'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show fields from `property`': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show table status like 'revision'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show fields from `revision`': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show table status like 'revision\_change'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show fields from `revision_change`': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show table status like 'setting'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show fields from `setting`': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show table status like 'setting\_history'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show fields from `setting_history`': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show table status like 'user'': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': MySQL server has gone away (2006)
mysqldump: Couldn't execute 'show fields from `user`': MySQL server has gone away (2006)

 一開始我把故障的錯誤點定位在"mysqldump: Couldn't execute 'show fields from `revision`': MySQL server has gone away (2006)"這段報錯上面,網上的部分建議是檢查max_allowed_packet的值,然后改得盡量大一些,我查看當前的值信息如下:

mysql> show global variables like 'max_allowed_packet';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| max_allowed_packet | 268435456 | 
+--------------------+-----------+
1 row in set (0.00 sec)

 可以看到當前的值已經是200M了,說明應該不是這個問題導致的,而且查看報錯,這里並沒有從select獲取大量數據,也沒有insert或者update大量數據.

我重新運行了一下腳本,過會兒又出現了相同的報錯了.

后來注意到有這么一段

mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `file_storage` at row: 29

 在一篇文章里看到了針對這個報錯的解決措施

https://ottomatik.groovehq.com/knowledge_base/topics/solving-error-2013-lost-connection-to-mysql-server-during-query-when-dumping-table

后來將timeout的值調大以后,就可以正常dump了

mysql> show global variables like '%timeout%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| connect_timeout            | 10    | 
| delayed_insert_timeout     | 300   | 
| innodb_lock_wait_timeout   | 100   | 
| innodb_rollback_on_timeout | OFF   | 
| interactive_timeout        | 28800 | 
| net_read_timeout           | 30    | 
| net_write_timeout          | 60    | 
| slave_net_timeout          | 3600  | 
| table_lock_wait_timeout    | 200   | 
| wait_timeout               | 28800 | 
+----------------------------+-------+
10 rows in set (0.00 sec)

mysql> set global net_read_timeout = 120; 
Query OK, 0 rows affected (0.03 sec)

mysql> set global net_write_timeout = 900;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like '%timeout%';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| connect_timeout            | 10    | 
| delayed_insert_timeout     | 300   | 
| innodb_lock_wait_timeout   | 100   | 
| innodb_rollback_on_timeout | OFF   | 
| interactive_timeout        | 28800 | 
| net_read_timeout           | 120   | 
| net_write_timeout          | 900   | 
| slave_net_timeout          | 3600  | 
| table_lock_wait_timeout    | 200   | 
| wait_timeout               | 28800 | 
+----------------------------+-------+
10 rows in set (0.00 sec)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM