Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php7.4 mysqli times out with "gone away"

Tags:

php

mysql

php-7.4

I have just installed php7.4, everything seems ok but when I try to go on my phpmyadmin, I can't : Note works fine in php7.3 before this installation

The error is :

mysqli_real_connect(): Unexpected server response while doing caching_sha2 auth: 109
 mysqli_real_connect(): (HY000/2006): MySQL server has gone away

looking my php mysql library :php7.4-mysql. it's installed.

Forget something ? Thank you.

NOTICE: Not enabling PHP 7.4 FPM by default.
NOTICE: To enable PHP 7.4 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php7.4-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Traitement des actions différées (« triggers ») pour libapache2-mod-php7.4 (7.4.
0-1+ubuntu19.10.1+deb.sury.org+1) ...

apt-cache policy php7.4
php7.4:
  Installé : 7.4.0-1+ubuntu19.10.1+deb.sury.org+1
  Candidat : 7.4.0-1+ubuntu19.10.1+deb.sury.org+1
 Table de version :
 *** 7.4.0-1+ubuntu19.10.1+deb.sury.org+1 500
        500 http://ppa.launchpad.net/ondrej/php/ubuntu eoan/main amd64 Packages
        500 http://ppa.launchpad.net/ondrej/php/ubuntu eoan/main i386 Packages
        100 /var/lib/dpkg/status
like image 926
Michel Avatar asked Nov 30 '19 21:11

Michel


People also ask

Has gone away MySQL?

The MySQL server has gone away error, means that MySQL server (mysqld) timed out and closed the connection. By default, MySQL will close connections after eight hours (28800 seconds) if nothing happens.

How to solve general error 2006 MySQL server has gone away?

The MySQL server has gone away (error 2006) has two main causes and solutions: Server timed out and closed the connection. To fix, check that wait_timeout mysql variable in your my. cnf configuration file is large enough, eg wait_timeout = 28800.


1 Answers

I had the same issue, but using mysql_native_password was not possible with PHP7.4-mysql-pdo, even on setting in my.cnf as it worked on PHP7.3-mysql-pdo.

I had to alter every user with this query:

ALTER USER 'username'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';

where username is the database username and password is the password of the database user.

like image 134
Markus Zeller Avatar answered Sep 24 '22 20:09

Markus Zeller