Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 537
Juliatzin Avatar asked Aug 14 '18 15:08

Juliatzin


2 Answers

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';
like image 154
abkrim Avatar answered Nov 06 '22 20:11

abkrim


the problem is good for safety, mybe.

but I use the command solve the problem:

  1. ALTER USER root@localhost IDENTIFIED WITH caching_sha2_password BY 'password';
  2. restart mysql
  3. try now

Hope you will not see this error again.

like image 3
Zenith Avatar answered Nov 06 '22 18:11

Zenith