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

后端 未结 29 1817
深忆病人
深忆病人 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:38

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

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

    In my case, setting the connection timeout interval to 6000 or something higher didn't work.

    I just did what the workbench says I can do.

    The maximum amount of time the query can take to return data from the DBMS.Set 0 to skip the read timeout.

    On Mac Preferences -> SQL Editor -> Go to MySQL Session -> set connection read timeout interval to 0.

    And it works

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

    I got the same issue when loading a .csv file. Converted the file to .sql.

    Using below command I manage to work around this issue.

    mysql -u <user> -p -D <DB name> < file.sql
    

    Hope this would help.

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

    I know its old but on mac

    1. Control-click your connection and choose Connection Properties.
    2. Under Advanced tab, set the Socket Timeout (sec) to a larger value.
    
    0 讨论(0)
  • 2020-11-22 16:41

    Three things to be followed and make sure:

    1. Whether multiple queries show lost connection?
    2. how you use set query in MySQL?
    3. how delete + update query simultaneously?

    Answers:

    1. Always try to remove definer as MySQL creates its own definer and if multiple tables involved for updation try to make a single query as sometimes multiple query shows lost connection
    2. Always SET value at the top but after DELETE if its condition doesn't involve SET value.
    3. Use DELETE FIRST THEN UPDATE IF BOTH OF THEM OPERATIONS ARE PERFORMED ON DIFFERENT TABLES
    0 讨论(0)
  • 2020-11-22 16:41

    check about

    OOM on /var/log/messages ,
    modify innodb_buffer_pool_size value ; when load data , use 50% of os mem ; 
    

    Hope this helps

    0 讨论(0)
提交回复
热议问题