0

I am running php and mysql using wamp server.

Php version : 7.0.33
MySql version : 8.0.21
MySql version in remote db server : Server version: 8.0.21 MySQL Community Server - GPL

When I try to connect to MySQL using PHP mysqli, I get the below error.

Warning: mysqli::real_connect(): Premature end of data (mysqlnd_wireprotocol.c:370) in C:\wamp64\www\mysql_ssh\mysql_test.php on line 17
Warning: mysqli::real_connect(): GREET packet 4 bytes shorter than expected in C:\wamp64\www\mysql_ssh\mysql_test.php on line 17
Warning: mysqli::real_connect(): Error while reading greeting packet. PID=29292 in C:\wamp64\www\mysql_ssh\mysql_test.php on line 17
Warning: mysqli::real_connect(): [2002] (trying to connect via tcp://x.x.x.x:33060) in C:\wamp64\www\mysql_ssh\mysql_test.php on line 17
Warning: mysqli::real_connect(): (HY000/2002): in C:\wamp64\www\mysql_ssh\mysql_test.php on line 17

Here is my code:

$ctx = mysqli_init();

$ctx->ssl_set('/mysql/client-key.pem', '/mysql/client-cert.pem', '/mysql/ca.pem', NULL, NULL);
$conn = $ctx->real_connect ($servername, $username, $password, $dbname, 33060, null);
if (!$conn) {
    die ('Connect error (' . $ctx->connect_errno . '): ' . $ctx->connect_error . "\n");
}

Code on line 17:

$conn = $ctx->real_connect ($servername, $username, $password, $dbname, 33060, null);

Dilani
  • 533
  • 1
  • 6
  • 22
  • 1
    Does this answer your question? ["Premature end of data" error with PHP](https://stackoverflow.com/questions/6099434/premature-end-of-data-error-with-php) – executable Sep 14 '20 at 08:44
  • @executable, no, those solutions didn't work – Dilani Sep 14 '20 at 10:12

0 Answers0