Error Code: 2013. Lost connection to MySQL server during query

后端 未结 29 1885
深忆病人
深忆病人 2020-11-22 16:22

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 als

相关标签:
29条回答
  • 2020-11-22 16:22

    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 ?

    0 讨论(0)
  • 2020-11-22 16:23
    SET @@local.net_read_timeout=360;
    

    Warning: The following will not work when you are applying it in remote connection:

    SET @@global.net_read_timeout=360;
    
    0 讨论(0)
  • 2020-11-22 16:23

    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.

    0 讨论(0)
  • 2020-11-22 16:24

    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.

    0 讨论(0)
  • 2020-11-22 16:24

    If all the other solutions here fail - check your syslog (/var/log/syslog or similar) to see if your server is running out of memory during the query.

    Had this issue when innodb_buffer_pool_size was set too close to physical memory without a swapfile configured. MySQL recommends for a database specific server setting innodb_buffer_pool_size at a max of around 80% of physical memory, I had it set to around 90%, the kernel was killing the mysql process. Moved innodb_buffer_pool_size back down to around 80% and that fixed the issue.

    0 讨论(0)
  • 2020-11-22 16:25

    Check if the indexes are in place first.

    SELECT *
    FROM INFORMATION_SCHEMA.STATISTICS
    WHERE TABLE_SCHEMA = '<schema>'
    
    0 讨论(0)
提交回复
热议问题