问题原文
原帖链接 · intcreator · CC BY-SA 4.0
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.
已采纳解答
原帖链接 · intcreator · CC BY-SA 4.0
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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
