MySQL錯誤Forcing close of thread的兩種解決方法

字號:


    今天導(dǎo)入sql總是提示錯誤
    代碼如下:
    ERROR 2013 (HY000): Lost connection to MySQL server during query
    ERROR 2006 (HY000): MySQL server has gone away
    No connection. Trying to reconnect...
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
    ERROR:
    Can't connect to the server
    網(wǎng)上試了很久,各種修改my.cnf,最后發(fā)現(xiàn)有人說是insert語句一次插入太多行造成的,解決辦法就是每次insert一行
    用mysqldump導(dǎo)出 加上參數(shù)--skip-extended-insert
    不清楚是不是跟mysql版本有關(guān),我的版本是
    mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
    總算是解決了問題,雖然還沒鬧明白為什么會有這種現(xiàn)象出現(xiàn),大家有知道的還請告之一下,不勝感激 1、修改mysql配置文件
    如果配置文件是my.ini,可以在在my.ini添加下面兩條內(nèi)容:
    skip-locking
    skip-name-resolve
    注意:在新版本的mysql中,skip-locking已經(jīng)被換成了skip-external-locking,如果使用skip-locking,可能會報如下錯誤:
    [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
    要注意查看日志。所以新版本mysql的寫法應(yīng)該是:
    skip-external-locking
    skip-name-resolve
    2、在mysql服務(wù)中進(jìn)行設(shè)置
    開始菜單 -> 運(yùn)行 -> services.msc,找到mysql的服務(wù)并雙擊,點擊恢復(fù)選項卡。
    第一次失?。耗J(rèn)是“不操作”,改成"重新啟動服務(wù)"。
    在下方的“重新啟動服務(wù):()分鐘后”添上“0”表示如果服務(wù)意外終止則立即重啟動。
    點擊確定使設(shè)置生效。
    但是有個問題產(chǎn)生了:如果這樣進(jìn)行修改,在任務(wù)管理器里無法結(jié)束mysql-nt進(jìn)程。所有如果需要停止進(jìn)程,先改回來再操作即可。