PHP Upgrade breaks connection to database

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 12.0.2):15.07
Operating system and version (eg, Ubuntu 17.04):FreeBSD (IOCAGE Jail on FreeNAS)
Apache or nginx version (eg, Apache 2.4.25): 2.4.39
PHP version (eg, 7.1):7.1.28 to 7.3

The issue you are facing: I successfully upgraded the PHP version to 7.3 as evidenced by the PHP Info, but NC is not responding. Examination of the httpd-error.log reveals an error connecting to the database.

Is this the first time you’ve seen this error? (Y/N):Y

Steps to replicate it:

  1. Install PHP 7.3

The output of your Nextcloud log in Admin > Logging:


The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

Screen Shot 2019-04-16 at 5.20.47 AM.png  

The output of your Apache/nginx/system log in /var/log/____:

[Tue Apr 16 05:19:03.025318 2019] [php7:error] [pid 8804] [client 66.199.23.246:15735] PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /usr/local/www/apache24/data/nextcloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /usr/local/www/apache24/data/nextcloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DB in /usr/local/www/apache24/data/nextcloud/lib/private/DB/Connection.php on line 64

Hi,

With the updates of PHP the modules are removed.
As a result you need to enable/ re-install mandatory modules again.
Please check the installation guide for that.

Even simpler is to use the search function of the forum because your question has already been asked and answered several times, like e.g. here:

Actually J-ed I did search, and this is a completely different issue. My php-info reveals that Apache IS using the new version of php. My issue is how to restore connectivity to MariaDB for NC.

I also had installed all of the php73 modules that were installed under php70, with the exception of mcrypt, as it no longer exists. Again, my issue is re-establishing the connection to the NC database.

Can you run:
php -m

and post the output here?
Are there any messages in the system logs about the connection failures to the DB?

This is a production system, so when I couldn’t get it working, I had to roll back to php70. When php73 was installed, this was the error (in the original post) given in the httpd-error.log:

[Tue Apr 16 05:19:03.025318 2019] [php7:error] [pid 8804] [client 66.199.23.246:15735] PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /usr/local/www/apache24/data/nextcloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /usr/local/www/apache24/data/nextcloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /usr/local/www/apache24/data/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DB in /usr/local/www/apache24/data/nextcloud/lib/private/DB/Connection.php on line 64

While I had php73 installed, the php info as served up by apache24 is attached.

I find this very hard to read on the screenshot and I can’t search for strings unfortunately.
I use MariaDB as well and upgraded to PHP73 a few weeks ago. Here is a list of all the modules I installed and use right now. Maybe this helps you to compare with your setup:

apcu
bz2
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gmp
hash
iconv
igbinary
intl
json
libsmbclient
libxml
mbstring
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
smbclient
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

I believe this was/ is a quite minimal setup and most of these modules are required for Nextcloud to run properly without warnings in the Overview.

And by the way: this part of the error message makes me believe a PHP module for DBs is missing:

Failed to connect to the database: An exception occured in driver: could not find driver

I think the message clearly states that the driver couldn’t be found. Afaik the required module is named “php7.3-mysql”. Make sure it is installed and correctly configured.

1 Like

You guys were absolutely correct on the missing module. In my case, on Freebsd, the module I had missed was named “mod_php73.” Once I corrected that, PHP 7.3.4 is running within Apache, and Nextcloud is running correctly as well.

The reason I started an upgrade to PHP7.3 in the first place was a belief that PHP7.0 was creating a problem with my ability to run pkg upgrade. The issue that I had was that a pkg upgrade was trying to remove Mariadb, which is needed for NextCloud. After upgrading to php7.3, the pkg upgrade to libreoffice 6.2.2_3 is trying to install mysql56-client: 5.6.43 which is incompatible with Mariadb because it installs in the same file location as the mariadb client.

Therefore, the original issue that I was trying to resolve is still present. For the time being, I have locked mariadb within pkg, but I would prefer to maintain the software through the pkg management and need to find a fix for this long term.