大网数据广告活动
网站运营与故障问答

Why can't update.php connect to my database when my site connects to it just fine?

· 52CE 我爱测

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 LocalSetti…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-09-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。