I’m using this software:
MAMP 4.2
MySQL 5.7.24 <-- PLEASE NOTE
PHP 7.4.1
Windows 10
This PHP code …
$dsn = 'mysql:host=localhost;dbname=mydatabase;';
try {
$dbh = new PDO($dsn, 'root', 'root');
}
catch (PDOException $e) {
echo $e;
}
… generates this error:
PDOException: PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]
Repeat: I am NOT using MySQL 8, and I repeat that fact because every article I’ve found on this topic claims that this error relates to MySQL version 8.
This SQL statement:
select user, plugin from mysql.user
Gives these results:
root mysql_native_password
mysql.session mysql_native_password
mysql.sys mysql_native_password
I’ve added this to my.ini:
default-authentication-plugin = mysql_native_password
And I’m still getting the error after restarting the MySQL server. I’ve attempted to upgrade to MySQL 8.0 using MAMP’s tools, and that doesn’t happen. Is it a PHP PDO issue?
By the way, since MAMP on Windows 10 ships with MySQL 5.7 — I have no idea why — and I frequently use MAMP because it’s so easy to install and requires virtually no configuration, ‘upgrade to MySQL 8.0’ isn’t really the answer I’m seeking because I presume there is solution that involves tweaking the configuration. If it’s the only answer that anyone has, I’ll guess I’ll ditch MAMP and go with something else.
I welcome your advice.
Thanks, David
2
Answers
Resolution: Windows is no longer a target environment for MAMP, so this is basically my fault for trying to use it on Windows. MAMP is intended for Mac OS X. So I'm switching to XAMPP. --David
If u think "Is it a PHP PDO issue?", here is my comment on it,
I’m new to this and working on my first html form to bind with mysql DB tables. I came across (The only proper) PDO tutorialans here is the URL : https://phpdelusions.net/pdo.