导入大型 sql 文件时 MySQL 服务器已消失

标签 mysql phpmyadmin

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

  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).

  2. 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] 等。例如:

[mysqld]
wait_timeout = 600
max_allowed_packet = 64M

然后重新启动服务器。要获取它们的值,请输入 mysql 客户端:

> select @@wait_timeout;
> select @@max_allowed_packet;

关于导入大型 sql 文件时 MySQL 服务器已消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12425287/

相关文章:

mysql - 将 TYPE 更改为 ENGINE(不同 MySQL 版本)

MySQL/PHPMyAdmin - 使用 512MB RAM 导入 15,000 行

php - 当我从 View 表中获取数据时出现 Laravel 错误

mysql - 选择具有特定行号值的行

俱乐部和员工数据库的 MySQL 数据库结构

mysql - 计算相似记录的数量、平均计数和特定计数的数量

MySQL 选择顶行按另一行分组

php - 浏览器中的模型 SQL 语法错误是否有更简单的快捷方式替换

phpmyadmin - 如何在 Webmin 上安装 phpmyadmin

c# - MySQL 连接到 phpMyAdmin 用 C# 创建的数据库