mysqldump匯出報錯"mysqldump: Error 2013 ... during query when dumping table

lhrbest發表於2020-05-12


mysqldump匯出報錯:

[root@lhrcentos76 mysql]# mysqldump --databases xxxx_hotel --single-transaction --hex-blob --set-gtid-purged=OFF --no-create-info --skip-triggers -uroot -pxxx -h119.3.xxx.xxx -P3306 -r xxxxx_hotel_data.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `sys_log` at row: 112614


解決:

---修改
set global wait_timeout=28800000;
set global net_read_timeout=28800;
set global net_write_timeout=28800;


匯出語句參考: https://support.huaweicloud.com/usermanual-rds/rds_migration_mysql.html



在mysqldump備份匯出的時候類似用如下語句匯出資料
mysqldump -uroot -p'passwd'  --opt --default-character-set=utf8 --triggers -R --hex-blob --single-transaction --no-autocommit --master-data=2 test_game mail >mail.sql
出現類似如下報錯:
mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `mail` at row: 1754283

 

查詢資料
大概說是因為mysqldump來不及接受mysql server端傳送過來的資料,Server端的資料就會積壓在記憶體中等待傳送,這個等待不是無限期的,當Server的等待時間超過net_write_timeout(預設是60秒)時它就失去了耐心,mysqldump的連線會被斷開,同時丟擲錯誤Got error: 2013: Lost connection。

 

增加 net_write_timeout可以解決上述的問題的。在實踐中發現,在增大 net_write_timeout後,Server端會消耗更多的記憶體,有時甚至會導致swap的使用(並不確定是不是修改 net_write_timeout所至)。建議在mysqldump之前修改net_write_timeout為一個較大的值(如1800),在 mysqldump結束後,在將這個值修改到預設的60。

 

在sql 命令行裡面設定臨時全域性生效用類似如下命令:
SET GLOBAL net_write_timeout=1800;

 

修改了這個引數後再備份,不再報錯
注意,這個引數不是mysqldump選項,而是mysql的一個配置引數。




About Me

........................................................................................................................

● 本文作者:小麥苗,部分內容整理自網路,若有侵權請聯絡小麥苗刪除

● 本文在itpub、部落格園、CSDN和個人微 信公眾號( DB寶)上有同步更新

● 本文itpub地址: http://blog.itpub.net/26736162

● 本文部落格園地址: http://www.cnblogs.com/lhrbest

● 本文CSDN地址: https://blog.csdn.net/lihuarongaini

● 本文pdf版、個人簡介及小麥苗雲盤地址: http://blog.itpub.net/26736162/viewspace-1624453/

● 資料庫筆試面試題庫及解答: http://blog.itpub.net/26736162/viewspace-2134706/

● DBA寶典今日頭條號地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826

........................................................................................................................

● QQ群號: 230161599 、618766405

● 微 信群:可加我微 信,我拉大家進群,非誠勿擾

● 聯絡我請加QQ好友 646634621 ,註明新增緣由

● 於 2020-05-01 06:00 ~ 2020-05-30 24:00 在西安完成

● 最新修改時間:2020-05-01 06:00 ~ 2020-05-30 24:00

● 文章內容來源於小麥苗的學習筆記,部分整理自網路,若有侵權或不當之處還請諒解

● 版權所有,歡迎分享本文,轉載請保留出處

........................................................................................................................

小麥苗的微店https://weidian.com/s/793741433?wfr=c&ifr=shopdetail

小麥苗出版的資料庫類叢書http://blog.itpub.net/26736162/viewspace-2142121/

小麥苗OCP、OCM、高可用網路班http://blog.itpub.net/26736162/viewspace-2148098/

小麥苗騰訊課堂主頁https://lhr.ke.qq.com/

........................................................................................................................

使用 微 信客戶端掃描下面的二維碼來關注小麥苗的微 信公眾號( DB寶)及QQ群(DBA寶典)、新增小麥苗微 信, 學習最實用的資料庫技術。

........................................................................................................................

歡迎與我聯絡

 

 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2691662/,如需轉載,請註明出處,否則將追究法律責任。

相關文章