0

I can't connect to my server. Here are the mistakes it gives me:

Warning: mysqli::__construct(): MySQL server has gone away in C:\xampp\htdocs\www\PHP-Project\logic\db_connection.php on line 3

Warning: mysqli::__construct(): Error while reading greeting packet. PID=8632 in C:\xampp\htdocs\www\PHP-Project\logic\db_connection.php on line 3

Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in C:\xampp\htdocs\www\PHP-Project\logic\db_connection.php on line 3

Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\www\PHP-Project\logic\db_connection.php on line 3

This is my connection file:

define("HOST", "localhost:81");
define("DB_USER", "root");
define("DB_PASSWORD", "");
define("DB_NAME", "bulitfactory_person_cv");

$db_connection = new mysqli(HOST, DB_USER, DB_PASSWORD, DB_NAME);

if ($db_connection->connect_error) {
    die("Connection failed. ".$db_connection->connect_error);
}

Please, help me!

Anna Nikolova
  • 57
  • 2
  • 8
  • Possible duplicate of [MySQL server has gone away and Error while reading greeting packet](https://stackoverflow.com/questions/42140547/mysql-server-has-gone-away-and-error-while-reading-greeting-packet) – aynber Aug 22 '17 at 11:57
  • 2
    Is your mysql really running on port 81? The default is 3306. Try removing the port if it is 3306, or add it in separately as the 5th parameter if it's not 3306. – aynber Aug 22 '17 at 11:58
  • 2
    Possible duplicate of [ERROR 2006 (HY000): MySQL server has gone away](https://stackoverflow.com/questions/10474922/error-2006-hy000-mysql-server-has-gone-away) – Script47 Aug 22 '17 at 11:58
  • You can't specify a host in the format `host:port` - the port is a separate parameter. – iainn Aug 22 '17 at 12:01
  • Nothing happens again... – Anna Nikolova Aug 22 '17 at 12:23
  • "Warning: mysqli::__construct(): Error while reading greeting packet. PID=8632 in C:\xampp\htdocs\www\PHP-Project\logic\db_connection.php on line 3" sounds to me there is een connection mismatch... maybe you are using a to old php version to connect to the newer mysql server. – Raymond Nijland Aug 22 '17 at 12:48

2 Answers2

1

try it to increase max_allowed_packet and restart the server

0

Add log_warnings=2 within [mysqld]section to your .ini/.cfg file, shutdown restart mysql and you should have maximum connection failure information in your error.log.

Wilson Hauck
  • 2,094
  • 1
  • 11
  • 19