問題描述
我試圖通過phpMyAdmin導入一個大的sql文件...但它一直顯示錯誤
I tried to import a large sql file through phpMyAdmin...But it kept showing error
'MySql 服務器已經消失'
'MySql server has gone away'
怎么辦?
推薦答案
如前所述 這里:
MySQL 服務器的兩個最常見的原因(和修復)已經消失(錯誤 2006)是:
Two most common reasons (and fixes) for the MySQL server has gone away (error 2006) are:
服務器超時并關閉連接.如何修復:
Server timed out and closed the connection. How to fix:
檢查mysqld的my.cnf配置文件中的wait_timeout變量是否足夠大.在 Debian 上:
sudo nano/etc/mysql/my.cnf
,設置wait_timeout = 600
秒(可以當錯誤 2006 消失時調整/減少此值),然后sudo/etc/init.d/mysql restart
.我沒有檢查,但默認值wait_timeout 可能約為 28800 秒(8 小時).
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).
服務器丟棄了不正確或過大的數據包.如果 mysqld 得到一個太大或不正確的數據包,它假定某些東西已經客戶端出錯并關閉連接.你可以增加通過增加值的最大數據包大小限制my.cnf 文件中的 max_allowed_pa??cket.在 Debian 上:sudo nano/etc/mysql/my.cnf
,設置max_allowed_pa??cket = 64M
(可以當錯誤 2006 消失時調整/減少此值),然后 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
.
請注意,MySQL 選項文件的命令尚未作為注釋提供(例如在 php.ini 中).因此,您必須在 my.cnf
或 my.ini
中鍵入任何更改/調整,并將它們放在 mysql/data
目錄或任何其他路徑,在適當的選項組下,例如 [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
然后重啟服務器.要獲取它們的值,請在 mysql 客戶端中輸入:
Then restart the server. To get their values, type in the mysql client:
> select @@wait_timeout;
> select @@max_allowed_packet;
這篇關于導入大型 sql 文件時 MySQL 服務器已消失的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!