I can connect the database with Maria client with --ssl options on application server:
mariadb -h [Address] -P [Port] -u [DB admin user] -p --ssl
But tried to connect the same database on same server with PHP PDO, we got the error message with:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client[client_ed25519]
I have added below options to PDO connection for simulate the --ssl options
PDO::MYSQL_ATTR_SSL_CA => true,
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
Here is my testing code piece:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$options = [
PDO::MYSQL_ATTR_SSL_CA => true,
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
];
try {
$conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password, $options);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
Database version: MariaDB 10.5