Reset password with OCC : Failed to connect to the database: An exception occurred in driver: could not find driver in xxx connection : 72

Nextcloud version (eg, 20.0.5): Nextcloud 20.0.3.2
Operating system and version (eg, Ubuntu 20.04): SMP Debian 5.7.10

Hello, I am trying to reset my admin password. Indeed, i had few problems that I was able to handle (the USB with the OS died when I away). I decided to reinstall OMV.
When i restarted NC (3 weeks later), my password expired (both my user and my admin). When I tried to send an email to reset, I do not receive any email (and I don’t see it in my sent email in the email configured in config.php → probably I did not )

I looked on the forum.
I found that I can reset the admin password with OCC.
Then I tried this command :
$ sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin

(well, I am not using the HHTP User, I can’t find how I am suppose to do it…)

Well, I execute this command with root permission. But I have this error :

Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:72

The whole text :

#0 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(1449): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(892): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/nextcloud/lib/private/DB/Connection.php(202): Doctrine\DBAL\Connection->executeQuery('SELECT * FROM `...', Array, Array, NULL)
#3 /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php(206): OC\DB\Connection->executeQuery('SELECT * FROM `...', Array, Array)
#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(217): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigValues()
#7 /var/www/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApps()
#8 /var/www/nextcloud/lib/private/legacy/OC_App.php(949): OC\AppConfig->getValues(false, 'installed_versi...')
#9 /var/www/nextcloud/lib/private/Server.php(668): OC_App::getAppVersions()
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#11 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#12 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OC\\Memcache\\Fac...')
#13 /var/www/nextcloud/lib/private/ServerContainer.php(156): OC\AppFramework\Utility\SimpleContainer->query('OC\\Memcache\\Fac...', true)
#14 /var/www/nextcloud/lib/private/Server.php(1677): OC\ServerContainer->query('OC\\Memcache\\Fac...')
#15 /var/www/nextcloud/lib/private/Server.php(1017): OC\Server->getMemCacheFactory()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#17 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#18 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OCP\\Lock\\ILocki...')
#19 /var/www/nextcloud/lib/private/ServerContainer.php(156): OC\AppFramework\Utility\SimpleContainer->query('OCP\\Lock\\ILocki...', true)
#20 /var/www/nextcloud/lib/private/Server.php(1977): OC\ServerContainer->query('OCP\\Lock\\ILocki...')
#21 /var/www/nextcloud/lib/private/Files/View.php(118): OC\Server->getLockingProvider()
#22 /var/www/nextcloud/lib/private/Server.php(395): OC\Files\View->__construct()
#23 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(155): OC\Server->OC\{closure}(Object(OC\Server))
#24 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(Pimple\Container))
#25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(122): Pimple\Container->offsetGet('OC\\Files\\Node\\H...')
#26 /var/www/nextcloud/lib/private/ServerContainer.php(156): OC\AppFramework\Utility\SimpleContainer->query('OC\\Files\\Node\\H...', true)
#27 /var/www/nextcloud/lib/private/Server.php(1324): OC\ServerContainer->query('OC\\Files\\Node\\H...')
#28 /var/www/nextcloud/lib/base.php(595): OC\Server->boot()
#29 /var/www/nextcloud/lib/base.php(1091): OC::init()
#30 /var/www/nextcloud/console.php(49): require_once('/srv/dev-disk-b...')
#31 /var/www/nextcloud/occ(11): require_once('/srv/dev-disk-b...')
#32 {main}root@Ninja://var/www/nextcloud# 

The issue you are facing:

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

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

logrotate state -- version 2
"/var/log/acpid.log" 2020-12-30-2:0:0
"/config/log/nginx/access.log" 2021-3-8-2:0:0
"/config/log/nginx/error.log" 2021-2-23-2:0:0
"/var/log/samba/*.log" 2020-12-30-2:0:0
"/config/log/php/error.log" 2021-3-8-2:0:0
"/var/log/samba/log.*" 2020-12-30-2:0:0

I am not sure it is the good log that is needed.

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

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'trusted_proxies' => 
  array (
    0 => 'swag',
  ),
  'overwrite.cli.url' => 'xxx',
  'overwritehost' => 'xxx',
  'overwriteprotocol' => 'https',
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxxx',
  'secret' => 'xxxx',
  'trusted_domains' => 
  array (
    0 => 'xxxx',
  ),
  'dbtype' => 'mysql',
  'version' => '20.0.7.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_xxxx',
  'dbpassword' => 'xxxx',
  'installed' => true,
  'twofactor_enforced' => 'true',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'maintenance' => false,
  'app_install_overwrite' => 
  array (
    0 => 'joplin',
  ),
  'mail_smtpmode' => 'sendmail',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_from_address' => 'xxxx',
  'mail_domain' => 'gmail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'xxxx',
  'mail_smtppassword' => 'xxxxx',
  'theme' => '',
  'loglevel' => 2,
);

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

-myIP- - - [29/Apr/2021:21:27:27 +0200] "GET /login HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:28 +0200] "GET /apps/photos/service-worker.js HTTP/1.1" 401 43 "myadress.com/apps/photos/service-worker.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:32 +0200] "GET / HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:32 +0200] "GET /login HTTP/1.1" 200 5085 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:32 +0200] "GET /apps/theming/styles?v=0 HTTP/1.1" 200 473 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:32 +0200] "GET /svg/core/logo/logo?color=fff&v=1 HTTP/1.1" 200 194 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:33 +0200] "GET /js/core/merged-template-prepend.js?v=84e578d0-0 HTTP/1.1" 200 2982 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:33 +0200] "GET /apps/accessibility/css/user-a82fd95db10ff25dfad39f07372ebe37 HTTP/1.1" 200 4268 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:33 +0200] "GET /apps/theming/favicon?v=0 HTTP/1.1" 200 8778 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:33 +0200] "GET /apps/theming/manifest?v=0 HTTP/1.1" 200 189 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - - [29/Apr/2021:21:27:35 +0200] "GET /apps/photos/service-worker.js HTTP/1.1" 401 43 "myadress.com/apps/photos/service-worker.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
-myIP- - user1 [29/Apr/2021:21:27:48 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:27:48 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:28:20 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:28:20 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:28:52 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:28:52 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:29:24 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:29:24 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:29:56 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:29:56 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:30:28 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:30:28 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:31:00 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:31:00 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:31:32 +0200] "GET /status.php HTTP/1.1" 200 151 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"
-myIP- - user1 [29/Apr/2021:21:31:32 +0200] "PROPFIND /remote.php/webdav/ HTTP/1.1" 503 337 "-" "Mozilla/5.0 (Windows) mirall/3.1.3stable-Win64 (build 20210218) (Nextcloud)"

Lot of logs with my mobile which tries to connect.

I hope it is clear…
Thanks a lot

Well, any idea.

I know understand the http user. I am corretly using it. but still it doest not work.

I tried to stop the Nextclodu container. It still doest not work.

Also, I had the log on the first post.

I am advancing I think. MySQL was not installed. So I installed it with

sudo apt sudo apt install php-mysql

Now, I have this error :

Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] Connection timed out in /srv/dev-disk-by-label-Cobra/appdata/nextcloud/config/www/nextcloud/lib/private/DB/Connection.php:72

When I find the solution, I will post it here.

I had pretty much the same problem.
Executing “sudo -u www:data php7.4 occ” resulted in the exact same error you mentioned.

Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:72

I tried a few things but ended up restoring a backup from the other day. But I still wana know what caused this behavior to avoid it in the future.

I used Nextcloud Version 20.0.9 + PHP 7.4.16

Hello,
I found the solution.
To change the password, you need to connect via the console on the portainer with the user 1000.

I was connecting via putty directly to the computer. So I was not inside the container/VM. So I did not have everything to connect to the database !
Sorry, I may use the wrong word, I am not a tech.

T

1 Like