我得到了错误代码:2013。当我试图使用MySQL工作台向表添加索引时,在查询错误期间失去了与MySQL服务器的连接。 我还注意到,每当我运行长查询时,它就会出现。

是否有增加超时值的方法?


当前回答

至:

编辑->首选项-> SQL编辑器

在“MySQL Session”组中可以看到三个字段,现在可以在其中设置新的连接间隔(以秒为单位)。

其他回答

我知道它很老,但在mac上

1. Control-click your connection and choose Connection Properties.
2. Under Advanced tab, set the Socket Timeout (sec) to a larger value.

新版本的MySQL WorkBench有一个选项可以更改特定的超时时间。

对我来说,它是在编辑→首选项→SQL编辑器→DBMS连接读取超时时间(秒):600

将值更改为6000。

此外,不勾选限制行,因为每次我想搜索整个数据集时都要设置一个限制,这会让人感到厌烦。

如果您在恢复一个大转储文件期间遇到这个问题,并且可以排除与网络有关的问题(例如在本地主机上执行),那么我的解决方案可能会有帮助。

我的mysqldump至少有一个INSERT太大,mysql无法计算。你可以通过输入show变量"net_buffer_length";在你的mysql-cli中。 你有三种可能:

increase net_buffer_length inside mysql -> this would need a server restart create dump with --skip-extended-insert, per insert one line is used -> although these dumps are much nicer to read this is not suitable for big dumps > 1GB because it tends to be very slow create dump with extended inserts (which is the default) but limit the net-buffer_length e.g. with --net-buffer_length NR_OF_BYTES where NR_OF_BYTES is smaller than the server's net_buffer_length -> I think this is the best solution, although slower no server restart is needed.

我使用以下mysqldump命令: mysqldump——skip-comments——set-charset——default-character-set=utf8——single-transaction——net-buffer_length 4096 DBX >转储文件

你应该在mysql配置文件中设置'interactive_timeout'和'wait_timeout'属性为你需要的值。

如果你的查询有blob数据,这个问题可以通过应用my.ini更改来修复,就像在这个答案中提出的那样:

[mysqld]
max_allowed_packet=16M

默认情况下,这将是1M(允许的最大值是1024M)。如果提供的值不是1024K的倍数,它将自动舍入到1024K的最接近倍数。

虽然引用的线程是关于MySQL错误2006,设置max_allowed_packet从1M到16M确实修复了2013年的错误,当我运行一个长查询时出现。

对于WAMP用户:您将在[wampmysqld]部分中找到该标志。