This page is a translated version of the page Manual:$wgDBserver and the translation is 71% complete.
数据库设置: $wgDBserver
数据库服务器主机名或 IP 地址。
引进版本:before 1.1.0


数据库主机名称或IP地址。在LocalSettings.php 找到。

如果你在MySQL上使用一个非标准端口,你可以使用'hostname:port'句法,例如:$wgDBserver = '';。 注意,当指定localhost作为主机名时使用端口号将不起作用,因为MySQL将通过套接字进行连接。 如果您的MySQL服务器在同一台服务器上,并且想通过非标准位置的套接字进行连接,您可以使用"localhost:socket",例如:$wgDBserver = 'localhost:/var/run/mysql/mysql.sock';

请尽可能使用IP地址,避免与每个与wiki的连接产生的DNS查找开销。 使用$wgDBserver = '';将比使用$wgDBserver = "";更快。
$wgDBport 只适用于PostgreSQL的配置。
On Windows, having MySQL as the backend, some users report that using localhost for the server name instead of increase the time to connect to the database a lot. So, in windows, it's recommended to use instead of localhost if MySQL is on the same machine. See this forum thread.

It may not work with plain IPv6 addresses, depending on the MySQL driver (libmysqlclient or mysqlnd); this is linked to this PHP bug. Also, when $wgDBssl is used, IPv6 addresses in the field subjectAlternativeName of a certificate are not recognised (it was not implemented in PHP when the verification of IPv4 addresses in certificates was implemented [1]). A workaround for these both cases is to use a DNS name pointing to an IPv6 address.


  • $wgDBservers - for multiple-server (primary/replica) setups or users of custom certificates for SSL encryption where $wgDBssl does not work.