Php occ maintenance mode files:scan An exception occurred in the driver: could not find driver in

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:

:/var/www/html# php occ
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 /var/www/html/lib/private/DB/Connection.php:163
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/html/lib/private/DB/ConnectionAdapter.php(200): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(121): OC\DB\ConnectionAdapter->getDatabasePlatform()
#5 /var/www/html/lib/private/AppConfig.php(1237): OC\DB\QueryBuilder\QueryBuilder->expr()
#6 /var/www/html/lib/private/AppConfig.php(262): OC\AppConfig->loadConfig()
#7 /var/www/html/lib/private/AppConfig.php(1378): OC\AppConfig->searchValues()
#8 /var/www/html/lib/private/App/AppManager.php(131): OC\AppConfig->getValues()
#9 /var/www/html/lib/private/App/AppManager.php(152): OC\App\AppManager->getInstalledAppsValues()
#10 /var/www/html/lib/private/legacy/OC_App.php(234): OC\App\AppManager->getInstalledApps()
#11 /var/www/html/lib/private/AppFramework/Bootstrap/Coordinator.php(90): OC_App::getEnabledApps()
#12 /var/www/html/lib/base.php(706): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#13 /var/www/html/lib/base.php(1181): OC::init()
#14 /var/www/html/console.php(48): require_once('...')
#15 /var/www/html/occ(11): require_once('...')
#16 {main}root@motor:/var/www/html# ls -lah
total 1.3M

Nextcloud version _ Hub 8 (29.0.2)
Operating system and version Raspbian GNU/Linux 10 (buster)
Apache or nginx version _ Apache/2.4.59 (Raspbian)
PHP version 8.2.20

The issue you are facing:

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

Steps to replicate it:

  1. At a root login type either
    php occ
    or
    sudo -u www-data php occ maintenance:mode --on
    or
    sudo -u www-data php occ files:scan --path=“shared/files/”

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file

<?php
$CONFIG = array (
  'instanceid' => '**************',
  'passwordsalt' => '******',
  'secret' => '*********',
  'trusted_domains' =>
  array (
    0 => '192.168.1.254',
    1 => '*.********.com',
    2 => '192.168.1.*',
  ),
  'datadirectory' => '/mnt/mount_point/nextcloud',
  'dbtype' => 'mysql',
  'version' => '29.0.2.2',
  'overwrite.cli.url' => 'http://192.168.1.254',
  'dbname' => '**********',
  'dbhost' => 'localhost:4****',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '*************',
  'dbpassword' => '*********',
  'installed' => true,
  'mail_from_address' => 'accounts',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '****.com',
  'mail_smtphost' => 'mail.****.com',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'accounts',
  'mail_smtppassword' => '**********,
);

The output of your Apache error log in /var/log/apache2/:

Fri Jun 21 12:19:53.714661 2024] [php:error] [pid 3605] [client 192.168.1.104:44214] PHP Fatal error:  Maximum execution time of 3600 seconds exceeded in /var/www/html/lib/private/Files/Storage/Local.php on line 530
[Fri Jun 21 12:19:53.720816 2024] [php:error] [pid 3605] [client 192.168.1.104:44214] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php:130\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php(130): PDOStatement->execute()\n#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1207): Doctrine\\DBAL\\Driver\\PDO\\Statement->execute()\n#2 /var/www/html/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php(292): Doctrine\\DBAL\\Connection->executeStatement()\n#3 /var/www/html/lib/private/DB/Connection.php(373): Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection->executeStatement()\n#4 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(393): OC\\DB\\Connection->executeStatement()\n#5 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#6 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(326): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#7 /var/www/html/lib/private/Lock/DBLockingProvider.php(258): OC\\DB\\QueryBuilder\\QueryBuilder->executeStatement()\n#8 [internal function]: OC\\Lock\\DBLockingProvider->releaseAll()\n#9 {main}\n\nNext Doctrine\\DBAL\\Driver\\PDO\\Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php:28\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Statement.php(132): Doctrine\\DBAL\\Driver\\PDO\\Exception::new()\n#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1207): Doctrine\\DBAL\\Driver\\PDO\\Statement->execute()\n#2 /var/www/html/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php(292): Doctrine\\DBAL\\Connection->executeStatement()\n#3 /var/www/html/lib/private/DB/Connection.php(373): Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection->executeStatement()\n#4 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(393): OC\\DB\\Connection->executeStatement()\n#5 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#6 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(326): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#7 /var/www/html/lib/private/Lock/DBLockingProvider.php(258): OC\\DB\\QueryBuilder\\QueryBuilder->executeStatement()\n#8 [internal function]: OC\\Lock\\DBLockingProvider->releaseAll()\n#9 {main}\n\nNext Doctrine\\DBAL\\Exception\\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /var/www/html/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:104\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1943): Doctrine\\DBAL\\Driver\\API\\MySQL\\ExceptionConverter->convert()\n#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1885): Doctrine\\DBAL\\Connection->handleDriverException()\n#2 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1213): Doctrine\\DBAL\\Connection->convertExceptionDuringQuery()\n#3 /var/www/html/3rdparty/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php(292): Doctrine\\DBAL\\Connection->executeStatement()\n#4 /var/www/html/lib/private/DB/Connection.php(373): Doctrine\\DBAL\\Connections\\PrimaryReadReplicaConnection->executeStatement()\n#5 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(393): OC\\DB\\Connection->executeStatement()\n#6 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#7 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(326): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#8 /var/www/html/lib/private/Lock/DBLockingProvider.php(258): OC\\DB\\QueryBuilder\\QueryBuilder->executeStatement()\n#9 [internal function]: OC\\Lock\\DBLockingProvider->releaseAll()\n#10 {main}\n\nNext OC\\DB\\Exceptions\\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /var/www/html/lib/private/DB/Exceptions/DbalException.php:71\nStack trace:\n#0 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(328): OC\\DB\\Exceptions\\DbalException::wrap()\n#1 /var/www/html/lib/private/Lock/DBLockingProvider.php(258): OC\\DB\\QueryBuilder\\QueryBuilder->executeStatement()\n#2 [internal function]: OC\\Lock\\DBLockingProvider->releaseAll()\n#3 {main}\n  thrown in /var/www/html/lib/private/DB/Exceptions/DbalException.php on line 71

There are no output errors in data/nextcloud.log of consequence.

You’re missing the PHP extension for your database. Did you perhaps upgrade PHP?

Or, another possibility is that your CLI mode PHP isn’t setup with the same PHP extensions for some reason. How is Nextcloud functioning at the web UI?

Hi Jtr,
It appears you’re right.
I finally saw that in /etc/php/ I had 2 folders. /8.2 & /8.3.
I remembered there had been an auto upgrade prompt which appeared in the web UI, which I proceeded with. It must have been then the issue occurred.
Checking through the php modules I realised that if I did NOT add the php version number, apt would just grab the correct one.
For example:
apt install php8.2-mysql
became
apt install php-mysql
I reinstalled all the php modules this way.
The correct versions were chosen and then all the permutations of the
php occ
command started working again.
Thank you for replying so fast jtr.

1 Like

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