問題描述
我試圖通過phpMyAdmin導(dǎo)入一個(gè)大的sql文件...但它一直顯示錯(cuò)誤
I tried to import a large sql file through phpMyAdmin...But it kept showing error
'MySql 服務(wù)器已經(jīng)消失'
'MySql server has gone away'
怎么辦?
推薦答案
如前所述 這里:
MySQL 服務(wù)器的兩個(gè)最常見的原因(和修復(fù))已經(jīng)消失(錯(cuò)誤 2006)是:
Two most common reasons (and fixes) for the MySQL server has gone away (error 2006) are:
服務(wù)器超時(shí)并關(guān)閉連接.如何修復(fù):
Server timed out and closed the connection. How to fix:
檢查mysqld的my.cnf配置文件中的wait_timeout變量是否足夠大.在 Debian 上:
sudo nano/etc/mysql/my.cnf
,設(shè)置wait_timeout = 600
秒(可以當(dāng)錯(cuò)誤 2006 消失時(shí)調(diào)整/減少此值),然后sudo/etc/init.d/mysql restart
.我沒有檢查,但默認(rèn)值wait_timeout 可能約為 28800 秒(8 小時(shí)).
check that wait_timeout variable in your mysqld’s my.cnf configuration file is large enough. On Debian:
sudo nano /etc/mysql/my.cnf
, setwait_timeout = 600
seconds (you can tweak/decrease this value when error 2006 is gone), thensudo /etc/init.d/mysql restart
. I didn't check, but the default value for wait_timeout might be around 28800 seconds (8 hours).
服務(wù)器丟棄了不正確或過大的數(shù)據(jù)包.如果 mysqld 得到一個(gè)太大或不正確的數(shù)據(jù)包,它假定某些東西已經(jīng)客戶端出錯(cuò)并關(guān)閉連接.你可以增加通過增加值的最大數(shù)據(jù)包大小限制my.cnf 文件中的 max_allowed_pa??cket.在 Debian 上:sudo nano/etc/mysql/my.cnf
,設(shè)置max_allowed_pa??cket = 64M
(可以當(dāng)錯(cuò)誤 2006 消失時(shí)調(diào)整/減少此值),然后 sudo/etc/init.d/mysql restart
.
Server dropped an incorrect or too large packet. If mysqld gets a packet that is too large or incorrect, it assumes that something has
gone wrong with the client and closes the connection. You can increase
the maximal packet size limit by increasing the value of
max_allowed_packet in my.cnf file. On Debian: sudo nano
/etc/mysql/my.cnf
, set max_allowed_packet = 64M
(you can
tweak/decrease this value when error 2006 is gone), then sudo
/etc/init.d/mysql restart
.
請(qǐng)注意,MySQL 選項(xiàng)文件的命令尚未作為注釋提供(例如在 php.ini 中).因此,您必須在 my.cnf
或 my.ini
中鍵入任何更改/調(diào)整,并將它們放在 mysql/data
目錄或任何其他路徑,在適當(dāng)?shù)倪x項(xiàng)組下,例如 [client]
、[myslqd]
等.例如:
Notice that MySQL option files do not have their commands already available as comments (like in php.ini for instance). So you must type any change/tweak in my.cnf
or my.ini
and place them in mysql/data
directory or in any of the other paths, under the proper group of options such as [client]
, [myslqd]
, etc. For example:
[mysqld]
wait_timeout = 600
max_allowed_packet = 64M
然后重啟服務(wù)器.要獲取它們的值,請(qǐng)?jiān)?mysql 客戶端中輸入:
Then restart the server. To get their values, type in the mysql client:
> select @@wait_timeout;
> select @@max_allowed_packet;
這篇關(guān)于導(dǎo)入大型 sql 文件時(shí) MySQL 服務(wù)器已消失的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!