Question

DO mysql managed database pdo problem

Posted September 9, 2019 1.1k views
DigitalOceanUbuntu 18.04

no problem when connect via DBeaver but,

unable to connect from droplet whit pdo (php 7.2),

converted downloaded ca-certificate from crt to pem and tried both crt and pem,

PDO::MYSQLATTRSSLVERIFYSERVER_CERT tried both, true and false

same result.

$dsn = ‘mysql:’;
$dsn .= 'host=’ . $this->Host . ’;’;
$dsn .= 'port=’ . $this->DBPort . ’;’;
if (!empty($this->DBName)) {
$dsn .= 'dbname=’ . $this->DBName . ’;’;
}
$dsn .= 'charset=utf8mb4;’;
$this->pdo = new PDO($dsn,
$this->DBUser,
$this->DBPassword,
array(
PDO::ATTRERRMODE => PDO::ERRMODEEXCEPTION,
PDO::MYSQLATTRUSEBUFFEREDQUERY => true,
PDO::MYSQLATTRSSLCA => ’/var/www/html/mycert.pem’,
PDO::MYSQL
ATTRSSLCIPHER => 'ECDHE-RSA-AES256-SHA384’,
PDO::MYSQLATTRSSLVERIFYSERVER_CERT => true
)
);

Unhandled Exception. SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

any help?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi,

This is probably because managed databases use MySQL 8 and the default authentication plugin is cachingsha2password.

This article, in particular the section labelled “A Note Regarding Password Authentication in MySQL 8” is probably going to help you!

https://www.digitalocean.com/community/tutorials/how-to-connect-to-managed-database-ubuntu-18-04

Thanks

by Mark Drake
If you're new to working with managed databases, the best way to perform certain tasks, like connecting to the database, may not be self-evident. In this guide, we will go over how to install client programs for a variety of database management systems, including PostgreSQL, MySQL, and Redis, on an Ubuntu 18.04 server. We'll also explain how to use these programs to connect to a managed database instance.
Submit an Answer