MySQL服务器已经消失,读取问候数据包时出错 [英] MySQL server has gone away and Error while reading greeting packet

查看:587
本文介绍了MySQL服务器已经消失,读取问候数据包时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么这样:

$dbh = new PDO('mysql:host=127.0.0.1:1812;dbname=nde_oldy-pn', 'root', '');

抛出此异常:

PDO::__construct(): MySQL server has gone away
PDO::__construct(): Error while reading greeting packet
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2006] MySQL server has gone away'
PDOException: SQLSTATE[HY000] [2006] MySQL server has gone away

YEAH !!我明白 ! MySQL决定不用我自己的命令去旅行! Grrrr!

YEAH !! I understand ! MySQL decided to go on a trip without me on his own command ! Grrrr!

我已尝试过此页面上的所有内容: MySQL文档(.5.2.9 MySQL服务器已经消失)

I've tried everything on this page : MySQL Documentation (.5.2.9 MySQL server has gone away)

上下文:
它运行与WAMP 3.0.6
(Apache 2.4.23; PHP 7.0.10; MySQL 5.7.14)
这样的网址:

Context : It run with WAMP 3.0.6 (Apache 2.4.23; PHP 7.0.10; MySQL 5.7.14) Url like this :


localhost:1812 / NDEfiveYEARSproject / index.php

localhost:1812/NDEfiveYEARSproject/index.php

httpd.conf如下:

httpd.conf like this :


听12.34.56.78:1812

Listen 12.34.56.78:1812

收听0.0.0.0:1812

Listen 0.0.0.0:1812

收听[:: 0]:1812

Listen [::0]:1812

ServerName localhost:1812

ServerName localhost:1812

my.ini如下:


port = 3306

port = 3306

key_buffer_size = 64M

key_buffer_size = 64M

max_allowed_pa​​cket = 200M

max_allowed_packet = 200M

是1812和3306端口已打开。

Yes 1812 and 3306 ports are open.

是入站和出站流量规则每个端口(1812和3306)已创建

Yes Incoming and outbound traffic rules for each port (1812 and 3306) have been created

IIS未运行

Skype和Teamviewer ...

Same for Skype and Teamviewer...

推荐答案

更改端口号。到3306

Change the port no. to 3306

$dbh =  new PDO('mysql:host=127.0.0.1;port=3306;dbname=nde_oldy-pn', 'root', '');

这篇关于MySQL服务器已经消失,读取问候数据包时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆