Editing
排除 MySQL 技術疑難問題
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== 錯誤 2013: 在查詢過程中與 MySQL 伺服器失去連接 === 訊息:錯誤代碼:2013。在查詢過程中與 MySQL 伺服器失去連接 情況:在執行包含超過 1,000,000 行的下列查詢後,我遇到了 '錯誤代碼:2013。在查詢過程中與 MySQL 伺服器失去連接' 的錯誤訊息。 <pre> INSERT IGNORE INTO `target`.`table` SELECT * FROM `source`.`table`; </pre> 解決方案: * 在 [https://www.mysql.com/products/workbench/ MySQL Workbench] 上增加 (1) '''資料庫連接保持活躍間隔(秒)''' 和 (2) '''資料庫連接讀取超時(秒)''' 的設定 <ref>[http://stackoverflow.com/questions/16877574/how-can-i-execute-sql-queries-that-take-longer-99-999-seconds-on-mysql-workbench 如何在 MySQL Workbench 上執行超過 99,999 秒的 SQL 查詢 - Stack Overflow]</ref><ref>[http://stackoverflow.com/questions/10563619/error-code-2013-lost-connection-to-mysql-server-during-query 錯誤代碼:2013。在查詢過程中與 MySQL 伺服器失去連接 - Stack Overflow]</ref>。修改設定後請重新啟動 MySQL Workbench。例如,預設的 '''資料庫連接讀取超時(秒)''' 設定為 30 秒,你可以增加到 6000 秒(100 分鐘)。 * 減少行數以縮短執行時間 (1) 使用 {{kbd | key=LIMIT}} 子句 (2) 或分割查詢大小,例如 {{kbd | key=<nowiki>MOD(column, 2) = 0</nowiki>}} 和 {{kbd | key=<nowiki>MOD(column, 2) > 0</nowiki>}},如果欄位是數字的話。 <pre> INSERT IGNORE INTO `target`.`table` SELECT * FROM `source`.`table` LIMIT 0, 10000; </pre>
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information