Error establishing a database connection after switching from PHP 7.3.5 to PHP 7.4.1

I’ve been having the same issue on both 5.4.1 and 5.4.2. I’ve narrowed it down a bit:

  • newly created sites - no problem switching
  • sites created before Local 5.4, can switch to PHP 7.4 without problem if they were using MySQL 5.7.28
  • sites created before Local 5.4, cannot switch to PHP 7.4 without problem if they were using MySQL 8.0.16

For those sites where switching didn’t work, the symptoms were:

  • connection to the site was very slow (>10 seconds)
  • eventually returned the following errors:
Warning: mysqli_real_connect(): Unexpected server response while doing caching_sha2 auth: 109 in /Users/.../app/public/wp-includes/wp-db.php on line 1633
Warning: mysqli_real_connect(): (HY000/2006): MySQL server has gone away in /Users/.../app/public/wp-includes/wp-db.php on line 1633

It wasn’t too hard to fix. For a site which wasn’t working on PHP7.4:

  • move the site files to a new location
  • delete the site in Local
  • recreate the site in Local, stop the site
  • replace the app directory in the new site with the app directory from the old site files
  • restart the site in Local
  • import the DB

Switching between PHP 7.3 and 7.4 works as expected.

@clay if there are any logs it would be helpful to see, let me know what to send.

1 Like