Nextcloud connexion à la database

What type of hardware are you using: Old laptop or computer
What YunoHost version are you running: 12.0.12 (stable)
What app is this about: Nextcloud

Describe your issue

Bonjour,

Depuis plusieurs jours lorsque je lance des commandes « occ » de Nextcloud j’ai les erreurs suivantes.
Par exemple ma commande « bash scan »

Qui comporte :

#!/bin/bash
set -eu
#Déplacement dans le répertoire de données Nextcloud.
cd /var/www/nextcloud

#Scan des fichiers des utilisateurs.
sudo -u nextcloud php8.2 /var/www/nextcloud/occ files:scan --all

J’ai à chaque fois sur toutes mes commandes le message suivant :

Si vous avez une idée, je ne sais pas comment on peut reconnecter la base.
Merci beaucoup pour votre partage, je n’ai pas trouvé de solution avec les recherches pour le moment

Merci
Guillaume

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/nextcloud/lib/private/DB/Connection.php:233
Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(458): OC\DB\Connection->connect()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(416): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(323): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/nextcloud/lib/private/DB/Connection.php(899): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/nextcloud/lib/private/DB/ConnectionAdapter.php(235): OC\DB\Connection->getDatabaseProvider()
#5 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(96): OC\DB\ConnectionAdapter->getDatabaseProvider()
#6 /var/www/nextcloud/lib/private/AppConfig.php(1211): OC\DB\QueryBuilder\QueryBuilder->expr()
#7 /var/www/nextcloud/lib/private/AppConfig.php(237): OC\AppConfig->loadConfig()
#8 /var/www/nextcloud/lib/private/AppConfig.php(1351): OC\AppConfig->searchValues()
#9 /var/www/nextcloud/lib/private/App/AppManager.php(126): OC\AppConfig->getValues()
#10 /var/www/nextcloud/lib/private/App/AppManager.php(147): OC\App\AppManager->getInstalledAppsValues()
#11 /var/www/nextcloud/lib/private/legacy/OC_App.php(191): OC\App\AppManager->getInstalledApps()
#12 /var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(48): OC_App::getEnabledApps()
#13 /var/www/nextcloud/lib/base.php(659): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#14 /var/www/nextcloud/lib/base.php(1134): OC::init()
#15 /var/www/nextcloud/console.php(28): require_once(‘…’)
#16 /var/www/nextcloud/occ(11): require_once(‘…’)
#17 {main}root@renaud:/usr/local/bin# nano Scan

Hi!

As stated by the docs (see your Nextcloud page on you admin panel), you have to use this command:

sudo -u nextcloud php8.3 --define apc.enable_cli=1 /var/www/nextcloud/occ …

Tell me if it solve your issue or not

Cheers

2 Likes

Hi, thanks a lot for your message.

I don’t have the error when i add your pre sentence to my occ command.
Why it solve the problem ?

Before it worked perfectly with out this for long month ago ?

Thanks a lot for helping

To be honest I don’t know
I’m not used to php

Anyway I’m glad it worked!

1 Like

Nextcloud uses php8.3 (but that was since a while ago).
The best way to run php commands for an app is to use the app shell as it defines the correct version of php and some other settings. In instance for nextcloud :

# enter nextcloud shell

sudo yunohost app shell nextcloud

# run your php command (without specifying the version as it is defined by the shell) 

php occ files:scan --all

Note that you can use the app shell for every installed app. The home folder is $install_dir and the current user is the app

2 Likes

Thanks a lot for the tips.
I understand that is like you enter in Nextcloud world before performing some order.
But seems my “script” don’t play next lign with php occ files

Does it must be flagged with some argument before ?

Sorry for silly question

J’ai pas bien saisi ce que tu veux dire.
Sinon, quelle version est ton nextcloud ?

Je suis en version Nextcloud Hub 9 (30.0.8)

Le script corrigé n’a pas l’air de déclenché d’actions derrière. Lorsque je lance le mien, j’ai un « blocage » et ensuite, j’ai un retour du nombre de fichiers et de dossiers scanné.

Là comme rien ne se passait, je pense ou avoir fait une bêtise, ou c’est normal que rien ne se passe ensuite ?

Une idée de script pour nextcloud :

  • Créer un fichier : nano nc_files_scan.sh

  • Coller le code suivant et sauvegarder :

#!/bin/bash
YNH_HELPERS_VERSION=2.1
source /usr/share/yunohost/helpers
source /etc/yunohost/apps/nextcloud/scripts/_common.sh
install_dir="/var/www/nextcloud" 
app="nextcloud"
php_version="8.3"

exec_occ files:scan --all
  • Le rendre executable : chmod +x nc_files_scan.sh

  • Tester : ./nc_files_scan.sh

(à faire, ne pas hardcoder les variables)

1 Like

Merci, je vais tester sur un Raspberry, car je ne suis pas sûr de bien maitriser tout ce langage-là :), mais merci beaucoup pour la piste, je vais tester

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