6

I'm trying to upgrade my MediaWiki installation. My site runs just fine locally at http://localhost:8888/. I can connect to my database using the "Socket" connection on Sequel Pro on port 8888. My database settings in LocalSettings.php look like this:

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "lifesitedb";
$wgDBuser = "root";
$wgDBpassword = "root";

However, even though everything else seems fine, when I run php update.php in the maintenance directory, I get this error:

MediaWiki 1.33.0 Updater

Your composer.lock file is up to date with current dependencies!
[97ab0d1b306782d836a0662c] [no req]   Wikimedia\Rdbms\DBConnectionError from line 1213 of /Users/Brandon/Sites/LifeSite/site/includes/libs/rdbms/loadbalancer/LoadBalancer.php: Cannot access the database: Unknown error (localhost)
Backtrace:
#0 /Users/Brandon/Sites/LifeSite/site/includes/libs/rdbms/loadbalancer/LoadBalancer.php(758): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#1 /Users/Brandon/Sites/LifeSite/site/includes/GlobalFunctions.php(2637): Wikimedia\Rdbms\LoadBalancer->getConnection(integer, array, boolean)
#2 /Users/Brandon/Sites/LifeSite/site/maintenance/Maintenance.php(1375): wfGetDB(integer, array, boolean)
#3 /Users/Brandon/Sites/LifeSite/site/maintenance/update.php(147): Maintenance->getDB(integer)
#4 /Users/Brandon/Sites/LifeSite/site/maintenance/doMaintenance.php(96): UpdateMediaWiki->execute()
#5 /Users/Brandon/Sites/LifeSite/site/maintenance/update.php(266): require_once(string)
#6 {main}

It says it cannot access the database because of an unknown error. What could this possibly be? I'm sure the connection information is correct since the site runs fine and connecting to the database using Sequel Pro works as well. What is going on here?

I'm running PHP 7.1.23 on macOS 10.14.4. I'm using MAMP 5.4 to host MediaWiki locally.

3 Answers 3

6

I seem to have resolved this by explicitly adding the socket to the $wgDBserver variable in LocalSettings.php. To get the socket path, I ran this query in my SQL database manager:

show variables like 'socket'

The only result was the following:

/Applications/MAMP/tmp/mysql/mysql.sock

So I changed the variable in LocalSettings.php as follows:

$wgDBserver = "localhost:/Applications/MAMP/tmp/mysql/mysql.sock";

The update.php script was then able to connect to the database.

1

As an alternative, you can also try the following. It should work with MAMP for Mac with default MAMP Ports (e.g., 8889 for MySQL). If you personalized the ports, put the corresponding one for MySQL Port:

  1. Edit LocalSettings.php
  2. Search for line starting with $wgDBserver
  3. Replace variable so the whole line looks like as follows: $wgDBserver = "127.0.0.1:8889";
0

For me the problem was that I had at one point configured a separate user for admin tasks. The password was no longer valid and thus not working.

$wgDBadminuser = "root";
$wgDBadminpassword = "XXXXXXXXX";

Removing the admin credentials from LocalSettings.php solved it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.