Error establishing a database connection with PHP 7.2

Ubuntu 20.04:
Webmin version 1.960
Virtualmin version 6.13
WordPress 5.5.3

WordPress and PHP-FPM 7.4 is all ok.
When I change to PHP-FPM 7.2 or PHP-FPM 5.6 there is an error in Wordpress.

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.
_
Username and password in Wordpress are the same as with PHP 7.4
Database is ok with other sites running Wordpress on the same server.
The site with error shows phpinfo.php just normal.
When I switch back to PHP 7.4 all is ok.

I’m on AWS and my PHP Versions are:
PHP Version 7.4.12
PHP Version 7.2.34-8+ubuntu20.04.1+deb.sury.org+1
PHP Version 5.6.40-38+ubuntu20.04.1+deb.sury.org+1
Wordpress is 5.5.3

Hope to get some clue on this.

Hi,

Unfortunately it’s a bug and we just fixed it. Expect it to be fixed with Virtualmin 6.14.

You can apply this change manually by editing /usr/share/webmin/virtual-server/php-lib.pl file and restarting Webmin with /etc/webmin/restart command.

I’ve already applied that fix last week and it did remove the error in virtualmin when making the switch. But I’m sorry to say it didn’t change anything regarding the error in Wordpress about connection to database.

Ahh, okay. You need to install MySQL extension for other PHP versions as well:

apt-get install php5.6-mysql php7.2-mysql

You could have found explanation to an error if checked Logs and Reports > Error Log:

php5.6-mysql is already the newest version (5.6.40-38+ubuntu20.04.1+deb.sury.org+1).
php7.2-mysql is already the newest version (7.2.34-8+ubuntu20.04.1+deb.sury.org+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

The Apache Error log shows nothing.
The Access log shows: “GET /wp-admin/ HTTP/1.1” 500 3563 “http://www.xx.com/wp-admin/” "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) etc…

The Error I see on the website is like the headline says.

What do you want me to check?

When is ETA for Virtualmin 6.14 ?
Maybe it will take care of this problem.

Did you reload the Apache configuration?

I think it would be something like sudo apache2ctl graceful on Ubuntu. (I could be wrong. It’s happened.)

Richard

Yes, I restarted Apache and even rebooted the whole server.
PHP is ok as long as it doesn’t have to use MySql.

I’m curious: Why would you use php 7.2 on a Wordpress install when you have 7.4 installed as well?

That’s because some sites does not run well with php 7.4 or won’t run at all.
You could say it’s their problem, but we try to help till they get it fixed.

1 Like

What’s your MySQL version? Check it with,
mysql -V

mysql Ver 8.0.22-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.