I upgraded a Debian 9 "Stretch" server to Debian 10 "Buster", which also upgrades Mediawiki to version 1.31.

Trying to run update.php, it fails with "Cannot access the database: No database connection":

/var/lib/mediawiki/maintenance# php update.php
MediaWiki 1.31.10 Updater

Your composer.lock file is up to date with current dependencies!
[6b70dd5bdc9deadcca99506a] [no req]   Wikimedia\Rdbms\DBConnectionError from line 1004 of /usr/share/mediawiki/includes/libs/rdbms/database/Database.php: Cannot access the database: No database connection
Backtrace:
#0 /usr/share/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1140): Wikimedia\Rdbms\Database->reportConnectionError(string)
#1 /usr/share/mediawiki/includes/libs/rdbms/loadbalancer/LoadBalancer.php(750): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#2 /usr/share/mediawiki/includes/GlobalFunctions.php(2813): Wikimedia\Rdbms\LoadBalancer->getConnection(integer, array, boolean)
#3 /usr/share/mediawiki/maintenance/Maintenance.php(1311): wfGetDB(integer, array, boolean)
#4 /usr/share/mediawiki/maintenance/update.php(147): Maintenance->getDB(integer)
#5 /usr/share/mediawiki/maintenance/doMaintenance.php(94): UpdateMediaWiki->execute()
#6 /usr/share/mediawiki/maintenance/update.php(248): require_once(string)
#7 {main}

The database is Postgresql, and I can access it fine with psql etc.

In LocalSettings.php I have

## Database settings
$wgDBtype           = "postgres";
$wgDBserver         = "localhost";
$wgDBname           = "wikidb";
$wgDBuser           = "...hidden...";
$wgDBpassword       = "...hidden...";

# Postgres specific settings
$wgDBport           = "5432";
$wgDBmwschema       = "mediawiki";
$wgDBts2schema      = "public";

Thanks for any help...

MI