An exception occurred in the driver: could not find driver in /var/www/html/lib/private/DB/Connection.php:142

I am trying to upgrade from version 25 to 26. I have a stand alone installation on an ubuntu server. It was running php7.4 and when running

sudo -u www-data php occ upgrade

It required I upgrade to php8.0. I did that. Now I get this error below.

Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/html/lib/private/DB/Connection.php:142
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/html/lib/private/DB/Connection.php(264): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/html/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/html/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/html/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /var/www/html/lib/private/legacy/OC_App.php(976): OC\AppConfig->getValues()
#9 /var/www/html/lib/private/Server.php(729): OC_App::getAppVersions()
#10 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#11 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#12 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#13 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#15 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#17 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#18 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#19 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#21 /var/www/html/lib/private/Server.php(1110): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#23 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#24 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#25 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#27 /var/www/html/lib/private/Server.php(2065): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/html/lib/private/Files/View.php(119): OC\Server->getLockingProvider()
#29 /var/www/html/lib/private/Server.php(464): OC\Files\View->__construct()
#30 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#31 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#32 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#33 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#35 /var/www/html/lib/private/Server.php(1467): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/html/lib/base.php(623): OC\Server->boot()
#37 /var/www/html/lib/base.php(1165): OC::init()
#38 /var/www/html/console.php(48): require_once(‘…’)
#39 /var/www/html/occ(11): require_once(‘…’)

When you upgrade php, make sure you also install all the required php extensions for the upgraded version. The Ubuntu specific instructions might be useful:

https://docs.nextcloud.com/server/stable/admin_manual/installation/example_ubuntu.html

The full module list is here just in case:

https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation

I suspect that error is because you’re missing the one for your database, but you’re likely also missing the rest if you upgraded.

Thanks for the reply. I think I am doomed. I just don’t have enough knowledge to know what to do. I have been running nextcloud for years and love it. I have upgraded many times. I was at least on version 19 a long time ago. I ran the commands below but I get this error now.

OCP\HintException: [0]: Memcache OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

sudo apt install apache2 mariadb-server libapache2-mod-php php-gd php-mysql
php-curl php-mbstring php-intl php-gmp php-bcmath php-xml php-imagick php-zip

I should also add that I looked in /etc/php/8.0/mods-available/ and there is no apcu.ini file. It is present in /etc/php/7.4/mods-available. I upgraded from 7.4 to 8.0

I ended up getting it to work. First I had to run
apt install php8.0-apcu.
Then I added
apc.enable_cli = 1
to the file
/etc/php/8.x/mods-available/apcu.ini

1 Like

I wrote a script for safe php upgrade on Ubuntu with apache2.

The script works if the following requirements are met:

  1. The old php version (7.4) must still be fully installed.
    This condition is met if you have not yet explicitly uninstalled (with --purge) any old php7.4 packages.
  2. There must be no incomplete PHP installation of the new version.
    In your case it looks like not all pecl packages needed by your installation are installed. Therefore, if 1. is met, the already installed php8.0 packages should be removed first:
sudo apt-get remove --purge *php8.0*

If that is done, download the update-script:

sudo wget -qO /usr/local/bin/php-updater https://global-social.net/script/php-updater
sudo chmod +x /usr/local/bin/php-updater

execute the script simply by calling it:
sudo php-updater
it looks what php-version actually is installed and asks which new version you want to install. (First I would recommend 8.0). After the installation it migrates all settings from your old php-installation (php.ini for php-cli and php-apache2 or - in case you are using php-fpm - the php.ini for php-fpm and pool.d/www.conf for php-fpm) into the new version.
If you already have completely installed one or more new versions (e.g. 8.0 and 8.1), you can use the script for only the later step (the migration from all setting) by calling it
sudo php-updater 7.4 8.0
In this case, it would read the settings from your 7.4 Version and helps you to integrate them into the 8.0 version.

Run this command to control, if all php-versions are switched to the version you want. I would recommend to not leave it in automatic mode but choosing the respective manual mode so that no unintentional version changes can take place, but only after your conscious change (using this command):

for linkgroup in $(ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"); do sudo update-alternatives --config $linkgroup; done

finaly change the used libapache2-mod-php in your apache server (if not yet done by installation routine):

sudo a2dismod php7.4
sudo a2enmod php8.0
sudo apachectl restart

After everything runs nice, you can remove all old php packages:

sudo apt-get remove --purge *php7.4*

Feel free to ask me anything you want prior to follow this steps

1 Like

Wow, thanks so much for the post. So everything seems to work fine without running the script. Should I still do it?

1 Like

If everything seems to work fine, then you seem to have made the right steps all by yourself.

You can at least skip part 1 of the script (the update process) and only do the second step, just to align the settings from the old installation with the new one: sudo php-updater 7.4 8.0 (assuming you updated to 8.0). You dont need to have any fear, it asks you before anny change would be made.

The step of switching the update-alternatives version control to manual mode is definitely a good choice to avoid accidental version switches and -mismatches. The next time you update your php Version, you know what you have to do [1]. (Simply calling sudo update-alternatives basically does exactly the same, it then shows ALL the alternatives managed by this tool and not just the php-related ones. Just skip the alternatives you want to leave with “Enter”.)

Much luck!



  1. For a future update, you can check if an updated version of the script is available, as I continue to develop it, adding new features from time to time. For example the update-alternatives switch, the automatic switch between libapache2-mod-php and php-fpm and back etc. and some analysis routines, to analyze errors or weak points to fix them in a dialog. ↩︎