Failed to connect to the database while removing warnings with occ

Nextcloud version: 19.0.4
Operating system and version: hosted (Linux 3.10.0-1127.8.2.el7.x86_64 x86_64)
Apache or nginx version: hosted (unknown)
PHP version: 7.4.12
Database: MariaDB

The issue you are facing:
Nextcloud shows 3 warnings, that should be fixed with:
./occ db:convert-filecache-bigint
./occ db:add-missing-columns
./occ db:add-missing-indices

All of these commands return this error:
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory in /httpdocs/nextcloud/lib/private/DB/Connection.php:67

Is this the first time you’ve seen this error?: No

Steps to replicate it:

  1. Switch NC to maintenance mode
  2. SSH to Server
  3. Issue the occ commands

The output of your Nextcloud log in Admin > Logging:

I don't know what log file you request

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

<?php
$CONFIG = array (
  'instanceid' => '***',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' => 
  array (
    0 => '***',
    1 => '***',
  ),
  'datadirectory' => '/home/httpd/vhosts/***',
  'dbtype' => 'mysql',
  'version' => '19.0.4.2',
  'overwrite.cli.url' => '***',
  'dbname' => '***',
  'dbhost' => 'localhost:8443',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '***',
  'dbpassword' => '***',
  'installed' => true,
  'maintenance' => false,
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => '***',
  'mail_domain' => '***',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '***',
  'mail_smtpport' => '25',
  'mail_smtpname' => '***',
  'mail_smtppassword' => '***',
  'theme' => '',
  'loglevel' => 2,
);

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

No such file or directory

I hope you’re aware of the fact that php consist of two components, a web and a cli component. Both need to be configured correctly to prevent any errors. In your case the php cli component is used to execute the occ commands. Therefore you should check that part of the system configuration first.

Afaik, the php database drivers are usually trying to use a socket connection to access a local database if “localhost” is used in a configuration. This might be the reason for the “No such file or directory” message.

In this case I would recomend to use e.g. the following syntax:

  'dbtype' => 'mysql',
  'dbhost' => 'localhost:/run/mysql/102/mysql.sock',
  ...

Thank you for your help. Does’nt help because I’m on a hosted CentOS VM without root rights.

Ok, in this case you should ask the administrator for help to get this problem fixed.