0

I don't know why this :

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

throw this exception :

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 !! I understand ! MySQL decided to go on a trip without me on his own command ! Grrrr!

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

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

httpd.conf like this :

Listen 12.34.56.78:1812

Listen 0.0.0.0:1812

Listen [::0]:1812

ServerName localhost:1812

my.ini like this :

port = 3306

key_buffer_size = 64M

max_allowed_packet = 200M

Yes 1812 and 3306 ports are open.

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

IIS is not running

Same for Skype and Teamviewer...

Community
  • 1
  • 1
Unrillaz Ti'bob
  • 71
  • 1
  • 1
  • 7
  • Surely you need to contact on the 3306 port, not the 1812 port? That's Apache and you want MySQL. – Pete Feb 09 '17 at 15:45

2 Answers2

0

Change the port no. to 3306

$dbh =  new PDO('mysql:host=127.0.0.1;port=3306;dbname=nde_oldy-pn', 'root', '');
Pete
  • 1,289
  • 10
  • 18
0

Encountered this MySQL server error today, have tried various solutions.

Uninstalling and re-installing XAMPP worked for me. :D