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

pdoexception means
pdoexception::("could not find driver") laravel mysql
pdoexception: sqlstate(hy000)
pdoexception $e
postgresql pdoexception could not find driver
what is pdo in php
pdo error handling
php exception code string

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.

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';

Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL , But $ php artisan migrate still returned. PDOException::("could not find driver"). I checked the shell (git bash for windows) with $ php --ini , that  Moving along through our in-depth PHP Exception Handling series, today we’ll be going over the PDOException. PHP Data Objects (or PDO) are a collection of APIs and interfaces that attempt to streamline and consolidate the various ways databases can be accessed and manipulated into a singular package.

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.

1 PDOException::("SQLSTATE[42S01]: Base table , 1 PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'projects' already exists"). Posted 1 year ago by  In response to the 15-May-2010 07:45 note from: samuelelliot+php dot net at gmail dot com Since the most base class Exception takes three arguments, and the previous exception is not the first,

After using $ mysql -uUser -pPa$$w0rd the MySQL connection could be opened with PHP using mysqli_real_connect() or PDO

Make sure that the User has caching sha2 password active, not a native password. (PHP 7.2.9-1, MySQL 8.0.12)

When changing to a native password PHP says

mysqli::real_connect(): Unexpected server respose while doing caching_sha2 auth: 109

With caching sha2 password active i always get:

mysqli::real_connect(): (HY000/1045): Access denied for user 'User'@'localhost' (using password: YES)

So tried to login from Shell using $ mysql, which succeeded, after this, i was able to connect with PHP. Seems like a Bug in the PHP mysqlnd.

Implementing a shell_exec('mysql -u'.$user.' -p"'.$password.'" -e quit > /dev/null 2>&1'); right before opening the MySQL connection, solves the issue, by now, for me.

Rebooting or restarting the MySQL Service, resets the cached password and the access denied message will pop again.

Hope this helps.


PDOException::("could not find driver"), PDOException::("could not find driver"). Posted 10 months ago by gemilyd. I'm getting this error. I do have a database file created Re: PHP MySQL PDOException: "could not find driver" I knew the IP address of the web-site and MySQL database were two different addresses. I thus made the assumption I could not use host=localhost, but that was the solution.

there is a way to solve this,

  1. remove MySQL
  2. Install it and choose use legacy authentication method ( Retain MySQL 5.x compatibility )

PDOException::("could not find driver"), PDOException::("could not find driver") - Dockerless install and config #1. Open. franciscohanna92 opened this issue on Mar 10, 2019 · 1 comment. Open  From: terrywongvip at qq dot com: Assigned: Status: Open: Package: PDO MySQL: PHP Version: 7.1.13: OS: CentOS release 6.8 (Final) Private report: No: CVE-ID: None

I've got `PDOException: SQLSTATE[HY000] [2002] No such file or , This was how I solved it on macOS: sudo mkdir /var/mysql sudo ln -s /​Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock. Source: Working with  I have just installed Debian Lenny with Apache, MySQL, and PHP and I am receiving a PDOException could not find driver.. This is the specific line of code it is referring to:

PDOException: SQLSTATE[42S02]: Base table or view not found , Going to the advanced settings tab (path admin/config/system/backup_migrate/​settings-advanced) I get this error message: PDOException:  Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python, Bootstrap, Java and XML.

PHP Exception Handling - PDOException, A deep dive into the PDOException class in PHP, including functional code samples illustrating how to use PDO and catch PDOExceptions. Quite often web-developers don't care enough about errors. If something goes wrong, you often see default Laravel texts like "Whoops, something went wrong" or, even worse, the exception code, which is not helpful at all to the visitor.

  • I have the same problem. :/ Did you fix it?
  • Yep. Downgrading mysql to previous version
  • I fixed it with setting default auth method mysql_native_password in my.cnf
  • This is really a "quick and dirty" solution and it's not appropriate for bigger applications. There will probably come an official fix for this.