导入大型sql文件时,MySQL Server已消失 [英] MySQL Server has gone away when importing large sql file

查看:91
本文介绍了导入大型sql文件时,MySQL Server已消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过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:

  1. 检查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小时).

  1. check that wait_timeout variable in your mysqld’s my.cnf configuration file is large enough. On Debian: sudo nano /etc/mysql/my.cnf, set wait_timeout = 600 seconds (you can tweak/decrease this value when error 2006 is gone), then sudo /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_packet = 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.cnfmy.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 Server已消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆