0

Edit: Based on the links sent over, it looks like no one read the question, but for those who see this in the future it seems the answer is: NO they are not compatible out of the box anymore and you do need to manually change the mysql auth'

We had a small app that we're using for local purposes and have an incredibly insecure simple PDO injection setup to access our mysql. (Works with MYSQL7)

return [
    'database' => [
        'username' => 'root',
        'password' => '',
        'connection' => 'mysql:host=127.0.0.1',
        'options' => [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
        ]
    ]
];

We upgraded to mysql8 and it looks like MYSQL8 auth is different.

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client 'name'

Upgraded to php7.3.1 and same issue.

Previous answers to similar questions say we need to adjust the MYSQL configuration. These posts are a year old though. And we are not competent to do this and feel comfortable.

Question: In 2019 November, is MYSQL8 & PHP7.3.1 & PDO not compatible out of the box with each other?

Is there a change we can make in our connection PDO code or is editing the MYSQL setup or switching to sqlite, etc our only options?

seamus
  • 2,681
  • 7
  • 26
  • 49

2 Answers2

0

No, they are not compatible out of box any more

seamus
  • 2,681
  • 7
  • 26
  • 49
0

PHP does not support new authentication method that is default in MySQL 8. I doubt if there was a time that PHP supported any default version of MySQL 8.

All what you need to do is to switch MySQL back to the previous method till the time a new method is supported by PHP.

You can do that simply by adding one option to the command that starts mysqld.

--default-authentication-plugin=mysql_native_password

and that's it.

Perhaps there is a solution to this problem in a form of some extension etc that you can add to PHP but at the time I search for such one, there wasn't any.

Jimmix
  • 5,644
  • 6
  • 44
  • 71