简体   繁体   English

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

[英]MySQL server has gone away - shared account

I'm trying to do the following but keep getting "MySQL server has gone away" 我正在尝试执行以下操作,但一直显示“ MySQL服务器已消失”

  1. Read approx 100,000 rows from an informix db (each row approx 400 chars). 从informix数据库读取大约100,000行(每行大约400个字符)。 No issues with this 没问题
  2. Insert the 100,000 rows into a MySQL table hosted on shared hostgator acct 将100,000行插入共享hostgator acct托管的MySQL表中

I received "MySQL server has gone away" and then updated my INSERT to use one INSERT command 我收到“ MySQL服务器已消失”,然后将我的INSERT更新为使用一个INSERT command

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

This didn't work so I tried opening a persistant connection ini_set('mysqli.reconnect', 'on') ; 这没有用,所以我尝试打开一个持久连接ini_set('mysqli.reconnect', 'on') ; and $db_mysqli = new mysqli('p:'.$host, $Username,$Pswd,$database); $db_mysqli = new mysqli('p:'.$host, $Username,$Pswd,$database);

This didn't help so I tried inserting 50,000 instead of 100,000 (which i prefer not to do) but still get MySQL server has gone away 这没有帮助,所以我尝试插入50,000而不是100,000(我不想这样做),但仍然使MySQL server has gone away

Since this is a shared hostgator account, I don't have access to php.ini nor mysql.cnf 由于这是一个共享的hostgator帐户,因此我无权访问php.inimysql.cnf

Any suggestions ? 有什么建议么 ?

Why it happened 为什么发生

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. 如果mysqld获取的数据包太大。 or out of order, it assumes that something has gone wrong with the client and closes the connection. 或顺序混乱,它假定客户端出了点问题,并关闭了连接。

What can be done 可以做什么

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. 避免此问题的简单方法是确保在mysqld服务器中将max_allowed_pa​​cket设置为大于客户端,并且确保所有客户端对max_allowed_pa​​cket使用相同的值。

What you can do?? 你可以做什么??

Since you're already using a hosting, ask the hosting support to fix the issue. 由于您已经在使用主机,因此请寻求主机支持以解决此问题。 Well if they cannot and you can reduce the query size reduce it, and if it doesn't solve your issue, trying changing the hosting. 好吧,如果他们不能,并且您可以减小查询大小,可以减小它;如果它不能解决您的问题,请尝试更改托管。

MYSQL Reference MYSQL参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM