[英]HY000 2006 MySQL server has gone away
So, I saw that there is a lot of questions about this problem, but i couldn't find any solution.所以,我看到有很多关于这个问题的问题,但我找不到任何解决方案。 I try in PHP to connecto to my database on hosting server but I get this: [HY000] [2006] MySQL server has gone away我尝试用 PHP 连接到我的托管服务器上的数据库,但我得到了这个: [HY000] [2006] MySQL 服务器已经消失
The code of PHP file looks like this: PHP 文件的代码如下所示:
<?php
$mysqli = new mysqli('database_addres', 'user', '', "database_name");
?>
I don't make some query calls or something like that.我不做一些查询电话或类似的事情。 I tried to connect by PDO and mysql_connect()
, but there is the same error.我尝试通过 PDO 和mysql_connect()
进行连接,但出现相同的错误。 connect_timeout
is set to 10, wait_timeout
to 200, innodb_buffer_pool_size
to 536870912. So everything seems to be ok. connect_timeout
设置为 10, wait_timeout
设置为 200, innodb_buffer_pool_size
为 536870912。所以似乎一切正常。 Do I miss something?我错过了什么吗?
The MySQL server has gone away (error 2006) has two main causes and solutions: Server timed out and closed the connection. MySQL 服务器消失(错误 2006)有两个主要原因和解决方案: 服务器超时和关闭连接。 To fix, check that wait_timeout mysql variable in your my.cnf configuration file is large enough.要修复,请检查 my.cnf 配置文件中的wait_timeout mysql 变量是否足够大。
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.如果 mysqld 收到一个太大或不正确的数据包,它会假定客户端出现问题并关闭连接。 To fix, you can increase the maximal packet size limit max_allowed_packet in my.cnf file, eg.要修复,您可以增加 my.cnf 文件中的最大数据包大小限制max_allowed_packet ,例如。 set max_allowed_packet = 128M, then restart your MySQL server: sudo /etc/init.d/mysql restart设置max_allowed_packet = 128M,然后重启你的 MySQL 服务器: sudo /etc/init.d/mysql restart
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.