php - MySQL 服务器已消失 - 共享帐户

标签 php mysql mysqli

我正在尝试执行以下操作,但不断收到“MySQL 服务器已消失”

  1. 从 informix 数据库中读取大约 100,000 行(每行大约 400 个字符)。 这没有问题
  2. 将 100,000 行插入到共享 Hostgator acct 上托管的 MySQL 表中

我收到“MySQL 服务器已消失”,然后更新了我的 INSERT使用一个INSERT command

例如:$queryMySQL = INSERT into table (field1, field2, field3,...) values ('A', '2017-02-01', ..), ('B', '2017-02-01', ..), ('C', '2017-02-01', ...),...'

这不起作用,所以我尝试打开持久连接 ini_set('mysqli.reconnect', 'on') ;和$db_mysqli = new mysqli('p:'.$host, $Username,$Pswd,$database);

这没有帮助,所以我尝试插入 50,000 而不是 100,000 (我不想这样做),但仍然得到 MySQL server has gone away

由于这是共享的 Hostgator 帐户,因此我无权访问 php.ini也不mysql.cnf

有什么建议吗?

最佳答案

为什么会发生

You can also get these errors if you send a query to the server that is incorrect or too large. If mysqld gets a packet that is too large. or out of order, it assumes that something has gone wrong with the client and closes the connection.

可以做什么

The easy way to avoid this problem is to ensure that max_allowed_packet is set bigger in the mysqld server than in the client and that all clients uses the same value for max_allowed_packet.

你能做什么?

由于您已经在使用托管,请请求托管支持来解决该问题。好吧,如果他们不能,您可以减少查询大小,如果它不能解决您的问题,请尝试更改托管。

MYSQL Reference

关于php - MySQL 服务器已消失 - 共享帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42045943/

相关文章:

php - 是否有将反斜杠添加到 Bash 命令行特殊字符的 PHP 函数?

php - 如何使用 PHP 将 Word 文档转换为 XML?

php - Bootstrap x-editable,PDO 更新问题

php - 从数据库中的单个单元格获取多个数据

php - 批量插入数据库

php - 来自数据库的 Codeigniter 动态路由

php - 将图像上传到服务器 PHP Android

php - 清理数据库存储过程调用/查询生成器/ Eloquent 用户输入

mysql - 如何使用 Rails+MySQL 获取分组记录的列表(ID)?

php - 使用这个自定义的 MySQLi 转义 PHP 函数有什么问题吗?