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);