After upgrading my linux, nextcloud fails to load or upgrade. Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver

Nextcloud version (eg, 20.0.5): 21.0.9.1
Operating system and version (eg, Ubuntu 20.04): Linux hostname 5.17.5-x86_64-linode154 #1 SMP PREEMPT Mon May 2 15:07:22 EDT 2022 x86_64
Apache or nginx version (eg, Apache 2.4.25): Again, I’m not sure…
PHP version (eg, 7.4): 7.4.30

The issue you are facing:

oot@linode (apache2 (master)): sudo -u www-data php7.4 /var/www/nextcloud/nextcloud/occ upgrade
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/DB/Connection.php:85
Stack trace:
#0 /mnt/extra_20GB/www/nextcloud/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /mnt/extra_20GB/www/nextcloud/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/DB/Connection.php(231): Doctrine\DBAL\Connection->executeQuery()
#3 /mnt/extra_20GB/www/nextcloud/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigValues()
#7 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApps()
#8 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/legacy/OC_App.php(975): OC\AppConfig->getValues()
#9 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/Server.php(683): OC_App::getAppVersions()
#10 /mnt/extra_20GB/www/nextcloud/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}()

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

Steps to replicate it: I just upgraded to Debian and now it stopped working

The output of your Nextcloud log in Admin > Logging: what is this? I can’t run nextcloud so I’ll ignore it.

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

root@linode (nextcloud ): cat config/config.php 
<?php
$CONFIG = array (
  'instanceid' => 'octdadd0ai7l',
  'passwordsalt' => 'O4VAyHlHFXsxxxxxxxFU22TJmT1hswLI',
  'secret' => 'N5Gd1UmA7HzxxxxxxxxxKYsnLDCkPpT/2etrswkx+/OvHCOs',
  'trusted_domains' => 
  array (
    0 => 'example.net',
  ),
  'datadirectory' => '/mnt/extra_20GB/www/nextcloud/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '21.0.9.1',
  'overwrite.cli.url' => 'http://linode.mydomain/nextcloud/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_redacted9',
  'dbpassword' => 'EQafkFOnFS7NI1K+NvEdnCcxIeze5f',
  'installed' => true,
  'maintenance' => false,
  'updater.secret' => '$2y$10$0m/0BtD4o8Fy7rV9LxxxxxxxxxIrhwCvxsNuICdznnnZZC0kPqCe',
  'theme' => '',
  'loglevel' => 2,
);

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

root@linode (nextcloud ): tail /var/log/apache2/error.log
[Fri Jun 17 15:56:59.024589 2022] [mpm_prefork:notice] [pid 1182] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Jun 17 15:56:59.088571 2022] [ssl:warn] [pid 259297] AH01916: Init: (linode.richcook.net:443) You configured HTTP(80) on the standard HTTPS(443) port!
[Fri Jun 17 15:56:59.117972 2022] [ssl:warn] [pid 259298] AH01916: Init: (linode.richcook.net:443) You configured HTTP(80) on the standard HTTPS(443) port!
[Fri Jun 17 15:56:59.121554 2022] [mpm_prefork:notice] [pid 259298] AH00163: Apache/2.4.53 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Fri Jun 17 15:56:59.121586 2022] [core:notice] [pid 259298] AH00094: Command line: '/usr/sbin/apache2'
[Fri Jun 17 16:30:42.481113 2022] [mpm_prefork:notice] [pid 259298] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Jun 17 16:30:43.538381 2022] [ssl:warn] [pid 328147] AH01916: Init: (linode.richcook.net:443) You configured HTTP(80) on the standard HTTPS(443) port!
[Fri Jun 17 16:30:43.571701 2022] [ssl:warn] [pid 328149] AH01916: Init: (linode.richcook.net:443) You configured HTTP(80) on the standard HTTPS(443) port!
[Fri Jun 17 16:30:43.575392 2022] [mpm_prefork:notice] [pid 328149] AH00163: Apache/2.4.53 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Fri Jun 17 16:30:43.575424 2022] [core:notice] [pid 328149] AH00094: Command line: '/usr/sbin/apache2'

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.
I’m able to run phpinfo(); in the nextcloud directory , just not nextcloud.
I’m sorry for the terrible bug report but I don’t really know what is needed here to explain my error best.

Do you have a backup you can roll back to?
Also, you should be able to ask Linode for assistance.

thanks so much for the reply.
Afetr much swearing and trying of things, I just moved my old nextcloud directory out of the way, deleted the MySql database, and reinstalled fresh. I then moved the data from the old users to the new ones and reindexed using occ and all was well.
Thanks