PHP 7.2.2 + mysql 8.0 PDO gives: authentication method unknown to the client [caching_sha2_password]

alter user 'username'@'localhost' identified with mysql_native_password by 'password';

As suggested by ailionx here : https://github.com/laradock/laradock/issues/1390


Found this somewhere, don't remember where (or I would credit), but it works for me until MySQL 8 gets better.

In MySQL shell (command prompt, whatever):

CREATE USER username@localhost identified with mysql_native_password by 'password';

Where username is the username and password is the password for that user.

Then you can add permissions in the shell - or in the Workbench as the user now exists with Authentication Type: Standard.


If you want to use MySQL >= 8 and you don't care about caching_sha2_password, just select the second option when you install.

enter image description here

Tags:

Mysql

Php

Pdo