0

I'm using MAMP and MySQL version 8.0.16 and php 7.4.1 Whenever I try to get the data from the database. I keep running into this error Error!: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

I've granted the user with all the privileges but still i keep running into this error and not sure why

try {
    $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
    foreach($dbh->query('SELECT * from testing') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}

Here's the code i'm running but keep running into dead end. Someone please help ! What am I doing wrong ?

mr-nobody
  • 97
  • 11
  • 1
    Does this answer your question? [PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client](https://stackoverflow.com/questions/52364415/php-with-mysql-8-0-error-the-server-requested-authentication-method-unknown-to) – waanofii.tech Aug 20 '20 at 21:28
  • have you tried this? [https://stackoverflow.com/questions/52364415/php-with-mysql-8-0-error-the-server-requested-authentication-method-unknown-to](https://stackoverflow.com/questions/52364415/php-with-mysql-8-0-error-the-server-requested-authentication-method-unknown-to) – RAlves Aug 20 '20 at 22:12
  • i fixed it by downgrading my MySQL version. – mr-nobody Aug 22 '20 at 17:27

0 Answers0