DO mysql managed database pdo problem

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::MYSQL_ATTR_SSL_VERIFY_SERVER_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::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::MYSQL_ATTR_SSL_CA => ‘/var/www/html/mycert.pem’, PDO::MYSQL_ATTR_SSL_CIPHER => ‘ECDHE-RSA-AES256-SHA384’, PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => true ) );

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

any help?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.


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

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