导入大型 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/40404755/

相关文章:

mysql - Phpmyadmin 登录被拒绝

MySQL 错误 - 字段 'id' 没有默认值

mysql - 云 SQL : Python Client API defaults to utf8mb3 character set on CSV file import

mysql - 如何在 MySQL 中选择具有给定标签的帖子的所有标签?

phpmyadmin - 使用 PHPMyAdmin 管理 Amazon RDS

php - 计算每行中真值的个数

mysql - phpmyadmin 数据库触发器创建查询

MySQL `INNER JOIN` 同一张表的倍数

PHP评论脚本

PHP 问题 : PDO Prepare() and Execute() with MYSQL IN() not working for arrays