Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: could not find driver

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, 20.0.5): 20.0.7
Operating system and version (eg, Ubuntu 20.04): debian 10
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.4): 7.4

The issue you are facing:

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

Steps to replicate it:

  1. php occ db:convert-type --all-apps mysql oc_mysql_user 127.0.0.1 new_db_name in SSH

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

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',
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => '192.168.8.245:9700',
    1 => 'nextcloud.konyks.biz',
  ),
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
  ),
  'forwarded_for_headers' => 
  array (
    0 => 'HTTP_CF_CONNECTING_IP',
  ),
  'dbtype' => 'sqlite3',
  'version' => '20.0.7.1',
  'overwrite.cli.url' => 'https://192.168.8.245:9700',
  'installed' => true,
  'maintenance' => false,
);

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

PASTE HERE

Trying to convert to mariaDB and everytime I try using the occ convert command I get,
“Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: could not find driver in /srv/dev-disk-by-label-media/containers/nextcloud/www/nextcloud/lib/private/DB/Connection.php:72”.
Have spent the last couple days trying to find a solution to no avail. Anyone have any ideas?

Have spent the last couple days trying to find a solution to no avail. Anyone have any ideas?

Several related discussions already exist on the forum which are related to your problem. See e.g.

https://help.nextcloud.com/search?q=failed%20to%20connect%20convert%20database

The usualy recommendation is to check the errors being logged to the Nextcloud server log and to make sure that your old and new database drivers are correctly loaded before you try to convert it to the new type.

There is already a detailed paragraph in the Adminsitrator guide which covers the database conversion:

https://docs.nextcloud.com/server/21/admin_manual/configuration_database/db_conversion.html?highlight=database%20convert#converting-database-type

Has anyone on the nextcloud team actually tried this? This seems to be a common error. From reading over the referenced documentation, I can see that it elides the fairly important step of creating the database, the database user, and the needed permissions/grants. I can say from recent experience that those directions won’t work as written, as noted on a recent post here.

I knew enough to do that and log into the database using the MySQL command line app. I know the database works and the conversion process did create the tables. But Nextcloud won’t connect to it with
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002]

Is the driver an issue? I have a php > MySQL installation (wordpress) and it still works.

I looked through some of those. Some got zero replies so who knows if those people just walked away. Others found their solutions in missing php modules that aren’t specified in TFM. As noted in another post the detailed post in TFM never mentions setting up the database with a username and permission grants before trying to convert to it, which would be a great first step, to ensure the database being converted to exists and is accessible.

I really have no idea how to solve this
sudo -u www php ./occ An unhandled exception has been thrown: Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/nextcloud/lib/private/DB/Connection.php:139

What driver? Would it be too much to ask what driver is being invoked here and/or which one is expected to connect to a mysql/mariadb instance that is currently accessible by another php web app (Wordpress)? I can access the database on the console using the same credentials and have verified the tables are all there.

I’ll assume my instance of Nextcloud is dead until further notice, I guess.

Technically I think the very first sentence in the docs[1] is trying to indicate you first need to set up a new database, but you’re right that it is very unclear and easy to miss. I’m drafting some proposed adjustments to the docs in that section to try to help clarify things[1].

[1] docs(admin): Clarify DB conversion steps and command usage by joshtrichards · Pull Request #11584 · nextcloud/documentation · GitHub