MySQL Workbench:如何保持连接有效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15712512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL Workbench: How to keep the connection alive
提问by Omar
Error Code: 2013. Lost connection to MySQL server during query
错误代码:2013。在查询过程中失去与 MySQL 服务器的连接
I am using MySQL Workbench. Also, I am running a batch of inserts, about 1000 lines total (Ex. INSERT INTO mytable SELECT * FROM mysource1; INSERT INTO mytable SELECT * FROM mysource2;...mysource3...mysource4
multiplied 1000 times) Each batch takes a considerable amount of time, some of them, more than 600 seconds.
我正在使用 MySQL 工作台。此外,我正在运行一批插入,总共大约 1000 行(例如INSERT INTO mytable SELECT * FROM mysource1; INSERT INTO mytable SELECT * FROM mysource2;...mysource3...mysource4
乘以 1000 次),每批都需要相当长的时间,其中一些超过 600 秒。
How can I configure workbench, to continue working overnight, without stopping and without losing the connection?
如何配置工作台,在不停止和不丢失连接的情况下继续工作一夜?
回答by Ignacio
From the now unavailableinternet archive:
从现在不可用的互联网档案:
Go to Edit -> Preferences -> SQL Editor and set to a higher value this parameter: DBMS connection read time out (in seconds). For instance: 86400.
Close and reopen MySQL Workbench. Kill your previously query that probably is running and run the query again.
转到编辑 -> 首选项 -> SQL 编辑器并将此参数设置为更高的值:DBMS 连接读取超时(以秒为单位)。例如:86400。
关闭并重新打开 MySQL Workbench。终止您之前可能正在运行的查询并再次运行该查询。
回答by Ljubitel
If you are using a "Standard TCP/IP over SSH" type of connection, under "Preferences"->"Others" there is "SSH KeepAlive" field. It took me quite a while to find it :(
如果您使用的是“基于 SSH 的标准 TCP/IP”类型的连接,则在“首选项”->“其他”下有“SSH KeepAlive”字段。找了好久才找到:(
回答by jidulberger
In 5.2.47 (at least on mac), go the location of the preferences is: MySQLWorkbench->Preferences->SQL Editor
在5.2.47(至少在mac上),去首选项的位置是:MySQLWorkbench->Preferences->SQL Editor
Then you'll see both:
然后你会看到两者:
DBMS connection keep-alive interval (in seconds): DBMS connection read time out (in seconds):
DBMS 连接保持活动间隔(以秒为单位):DBMS 连接读取超时(以秒为单位):
The latter is where you'll want to up the limit from 600 to something a bit more.
后者是您希望将限制从 600 提高到更多的地方。
回答by Abelgo
In my case after trying to set the SSH timeout on the command line and in the local server settings. @Ljubitel solution solved the issue form me.
就我而言,在尝试在命令行和本地服务器设置中设置 SSH 超时后。@Ljubitel 解决方案解决了我的问题。
One point to note is that in Workbench 6.2 the setting is now under advanced
需要注意的一点是,在 Workbench 6.2 中,设置现在处于高级状态
回答by Chris Dav
OK - so this issue has been driving me crazy - v 6.3.6 on Ubuntu Linux. None of the above solutions worked for me. Connecting to localhost mysql server previously always worked fine. Connecting to remote server always timed out - after about 60 seconds, sometimes after less time, sometimes more.
好的 - 所以这个问题让我发疯了 - Ubuntu Linux 上的 v 6.3.6。以上解决方案都不适合我。以前连接到 localhost mysql 服务器总是可以正常工作。连接到远程服务器总是超时 - 大约 60 秒后,有时更短,有时更多。
What finally worked for me was upgrading Workbench to 6.3.9 - no more dropped connections.
最终对我有用的是将 Workbench 升级到 6.3.9 - 不再断开连接。
回答by Tuncay G?ncüo?lu
If you are using a "Standard TCP/IP over SSH" type of connection, it might be the ssh server that keeps timing out, in which case, you would have to edit TCPKeepAlive related settings in /etc/ssh/sshd_config on your server.
如果您使用的是“基于 SSH 的标准 TCP/IP”类型的连接,则可能是 ssh 服务器一直超时,在这种情况下,您必须在服务器上的 /etc/ssh/sshd_config 中编辑 TCPKeepAlive 相关设置.
回答by Neal Garrett
I was getting this error 2013 and none of the above preference changes did anything to fix the problem. I restarted mysql service and the problem went away.
我在 2013 年收到此错误,上述偏好更改均未解决此问题。我重新启动了 mysql 服务,问题就消失了。
回答by kimbaudi
I had a similar problem where CREATE FULLTEXT
timed out after 30 seconds:
我有一个类似的问题,CREATE FULLTEXT
在 30 秒后超时:
Setting DBMS connection read timeout interval to 0 under Edit -> Preferences -> SQL Editor fixed the issue for me:
在 Edit -> Preferences -> SQL Editor 下将 DBMS connection read timeout interval 设置为 0 为我解决了这个问题:
Also, I did not have to restart mysql workbench for this to work.
此外,我不必重新启动 mysql 工作台即可使其正常工作。