Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

mysql

pdo

I'm using php 7.2.2 and mysql 8.0.

When I try to connect with the right credential I get this error:

PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]") 

Need help to troubleshoot the problem.

like image 260
Michele Carino Avatar asked Mar 03 '18 11:03

Michele Carino


2 Answers

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

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

like image 69
Szekelygobe Avatar answered Sep 28 '22 12:09

Szekelygobe


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.

like image 34
Reid Avatar answered Sep 28 '22 11:09

Reid