Error Code: 2013. Lost connection to MySQL server

2019-01-01 06:35发布

I got the Error Code: 2013. Lost connection to MySQL server during query error when I tried to add an index to a table using MySQL Workbench. I noticed also that it appears whenever I run long query.

Is there away to increase the timeout value?

26条回答
看淡一切
2楼-- · 2019-01-01 07:25

Try please to uncheck limit rows in in Edit → Preferences →SQL Queries

because You should set the 'interactive_timeout' and 'wait_timeout' properties in the mysql config file to the values you need.

查看更多
栀子花@的思念
3楼-- · 2019-01-01 07:28

Start the DB server with the comandline option net_read_timeout / wait_timeout and a suitable value (in seconds) - for example: --net_read_timeout=100.

For reference see here and here.

查看更多
闭嘴吧你
4楼-- · 2019-01-01 07:28

This happened to me because my innodb_buffer_pool_size was set to be larger than the RAM size available on the server. Things were getting interrupted because of this and it issues this error. The fix is to update my.cnf with the correct setting for innodb_buffer_pool_size.

查看更多
只若初见
5楼-- · 2019-01-01 07:29

Add the following into /etc/mysql/cnf file:

innodb_buffer_pool_size = 64M

example:

key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
innodb_buffer_pool_size = 64M
查看更多
君临天下
6楼-- · 2019-01-01 07:29

Thanks!It's worked. But with the mysqldb updates the configure has became:

max_allowed_packet

net_write_timeout

net_read_timeout

mysql doc

查看更多
高级女魔头
7楼-- · 2019-01-01 07:29

I ran into this while running a stored proc- which was creating lots of rows into a table in the database. I could see the error come right after the time crossed the 30 sec boundary.

I tried all the suggestions in the other answers. I am sure some of it helped , however- what really made it work for me was switching to SequelPro from Workbench.

I am guessing it was some client side connection that I could not spot in Workbench. Maybe this will help someone else as well ?

查看更多
登录 后发表回答