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 = "...";
$wgDBpassword = "...";
# Postgres specific settings
$wgDBport = "5432";
$wgDBmwschema = "mediawiki";
$wgDBts2schema = "public";
In the Mediawiki debug log, I also see
IP: 127.0.0.1
Start command line script update.php
[caches] cluster: EmptyBagOStuff, WAN: mediawiki-main-default, stash: db-replicated, message: SqlBagOStuff, session: SqlBagOStuff
[caches] LocalisationCache: using store LCStoreNull
[DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: calling initLB() before first connection.
[DBReplication] Wikimedia\Rdbms\LBFactory::getChronologyProtector: using request info {
"IPAddress": "127.0.0.1",
"UserAgent": false,
"ChronologyProtection": false,
"ChronologyPositionIndex": 0
}
[DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: failed to connect to database 0 at 'localhost'.
[DBConnection] Wikimedia\Rdbms\LoadBalancer::reportConnectionError: connection error: Unknown error ([Null])
[exception] [6b70dd5bdc9deadcca99506a] [no req] Wikimedia\Rdbms\DBConnectionError from line 1004 of /usr/share/mediawiki/includes/libs/rdbms/d
atabase/Database.php: Cannot access the database: No database connection
I'm now completely stuck...
Try commenting out:
The first setting's default value has changed; the second is obsolete.
For newer mediawiki versions, there are some pitfalls that breaks the mysql connection. Some attempts to fix are: