我尝试通过phpMyAdmin导入一个大的sql文件...但它一直显示错误
'MySql server has gone away'
要做什么?
最佳答案
如上所述here :
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:
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).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
, setmax_allowed_packet = 64M
(you can tweak/decrease this value when error 2006 is gone), thensudo /etc/init.d/mysql restart
.
编辑:
请注意,MySQL 选项文件的命令尚未可用作注释(例如在 php.ini 中)。因此,您必须在 my.cnf
或 my.ini
中键入任何更改/调整,并将它们放入 mysql/data
目录或任何其他路径,在适当的选项组下,例如 [client]
、[myslqd]
等。例如:
[mysqld]
wait_timeout = 600
max_allowed_packet = 64M
然后重新启动服务器。要获取它们的值,请在 mysql 客户端中输入:
> select @@wait_timeout;
> select @@max_allowed_packet;
关于导入大型 sql 文件时 MySQL 服务器消失了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40404755/