Occ cmd throws Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in

Hi,
The occ cmd is not working, and nothing else either…

I had a running installation on ubuntu 16.04 after trying to upgrade, I somehow managed to destroy most functions.

I am using:
nginx + php8.2
nc latest stable version (doesn´t run anymore)

I havent changed anything in the nc configuration

I have no option of upgrading ubuntu (VPS that doesn´t allow that) …

I have ssh root access, I can connect to the mysql db from there …

php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
random
Reflection
session
SimpleXML
sockets
SPL
sqlite3
standard
sysvsem
sysvshm
tokenizer
xmlreader
xmlwriter
zip
zlib

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 /var/www/html/lib/private/DB/Connection.php:140
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/html/lib/private/DB/Connection.php(262): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/html/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/html/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/html/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /var/www/html/lib/private/legacy/OC_App.php(803): OC\AppConfig->getValues()
#9 /var/www/html/lib/private/Server.php(733): OC_App::getAppVersions()
#10 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#11 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#12 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#13 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#15 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#17 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#18 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#19 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#21 /var/www/html/lib/private/Server.php(1115): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#23 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#24 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#25 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#27 /var/www/html/lib/private/Server.php(2067): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/html/lib/private/Files/View.php(106): OC\Server->getLockingProvider()
#29 /var/www/html/lib/private/Server.php(467): OC\Files\View->__construct()
#30 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server->OC{closure}()
#31 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}()
#32 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container->offsetGet()
#33 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer->query()
#35 /var/www/html/lib/private/Server.php(1469): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/html/lib/base.php(638): OC\Server->boot()
#37 /var/www/html/lib/base.php(1180): OC::init()
#38 /var/www/html/console.php(48): require_once(‘…’)
#39 /var/www/html/occ(11): require_once(‘…’)

systemctl status php-8.2-fpm
● php-8.2-fpm.service - The PHP 8.2 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php-8.2-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-09-08 09:17:51 CEST; 3h 27min ago
Main PID: 14298 (php-fpm)
CGroup: /system.slice/php-8.2-fpm.service
├─14298 php-fpm: master process (/etc/php/8.2/etc/php-fpm.conf)
├─14302 php-fpm: pool www
└─14303 php-fpm: pool www

systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: active (running) since Fri 2023-09-08 09:17:52 CEST; 3h 28min ago
Process: 14301 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 14311 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Process: 14309 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 14306 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 14310 (nginx)
CGroup: /system.slice/nginx.service
├─14310 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
├─14312 nginx: worker process
├─14313 nginx: worker process
└─14314 nginx: worker process

mysql -u ncloud -pveryverysecretpw
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 77
Server version: 8.0.25 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> prompt \u@\h [\d]
PROMPT set to ‘\u@\h [\d]’
ncloud@localhost [(none)]show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| ncloud |
±-------------------+
2 rows in set (0.00 sec)

ncloud@localhost [(none)]use ncloud
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
ncloud@localhost [ncloud]show tables;
±--------------------------------+
| Tables_in_ncloud |
±--------------------------------+
| oc_accounts |
| oc_accounts_data |
| oc_activity |

Anybody any further idea ?

Thanks

Also an upgrade didn´t change anything… :frowning:

cd temp
mkdir nc_latest
cd nc_latest/
wget https://download.nextcloud.com/server/releases/latest.zip
crontab -u www-data -e

unzip latest.zip
systemctl stop nginx
systemctl stop php-8.2-fpm

cp -R nextcloud/ /var/www/html
chown -R www-data:www-data /var/www/html
find /var/www/html -type d -exec chmod 750 {} ;
find /var/www/html -type f -exec chmod 640 {} ;
cp /var/www/html_old/config/config.php /var/www/html/config/config.php
cd /var/www/html/
systemctl start nginx
systemctl start php-8.2-fpm
sudo -u www-data php occ upgrade

===> same output:

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 /var/www/html/lib/private/DB/Connection.php:140
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/html/lib/private/DB/Connection.php(262): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/html/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/html/lib/private/AppConfig.php(184): OC\AppConfig->loadConfigValues()
#7 /var/www/html/lib/private/AppConfig.php(374): OC\AppConfig->getApps()

Ever solve this? I’ve got the same issue after running into loads of problems after updating php

No, I didn´t.

(Un)fortunatelly my hosting provider had a massive HW crash 4 weeks ago, and they gave me a completly new VPS + a few TB empty space :frowning: