PDOException::("PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109") with MySQL 8 / PHP 7.2 / Laravel

Juliatzin picture Juliatzin · Aug 14, 2018 · Viewed 7k times · Source

I just installed my dev environnement.

When I try to connect mysql db via SequelPro, I get:

Authentication plugin 'caching_sha2_password' cannot be loaded

As stated in: Authentication plugin 'caching_sha2_password' cannot be loaded, I ran:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';

Then I could connect my DB via SequelPro

But when I execute Laravel Command:

php artisan migrate

I get:

PDOException::("PDO::__construct(): Unexpected server respose while doing caching_sha2 auth: 109")

What should I do now ?

PD: I use Laravel Valet on Mac, and Laravel 5.6.

Answer

abkrim picture abkrim · Dec 22, 2018

You must alter use in your laravel app via shell with mysql command

ALTER USER 'user'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'your password';
ALTER USER 'user'@'%' IDENTIFIED WITH caching_sha2_password BY 'your password';