我正在尝试执行以下操作,但不断收到“MySQL 服务器已消失”
- 从 informix 数据库中读取大约 100,000 行(每行大约 400 个字符)。 这没有问题
- 将 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.
你能做什么?
由于您已经在使用托管,请请求托管支持来解决该问题。好吧,如果他们不能,您可以减少查询大小,如果它不能解决您的问题,请尝试更改托管。
关于php - MySQL 服务器已消失 - 共享帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42045943/