Manual:$wgDBprefix

From Linux Web Expert

<translate> Database settings</translate>: $wgDBprefix
Table name prefix.
<translate> Introduced in version:</translate>1.4.0
<translate> Removed in version:</translate><translate> still in use</translate>
<translate> Allowed values:</translate>(string)
<translate> Default value:</translate>''

Details

Table name prefix. This should be alphanumeric, contain neither spaces nor hyphens, and end in "_". If you only have access to a single database and wish to install more than one version of MediaWiki, or have other applications that also use the database, you can give the table names a unique prefix to stop any naming conflicts or confusion.

For example, if you use the prefix 'wiki_' then the table 'page' will be named 'wiki_page' instead.

You need to set this at the time of initial configuration, or manually change the table names at a later date. Changing this setting does not automatically update the names of the tables in your database.

This setting is NOT used if your database is PostgreSQL: instead, schemas are used (see $wgDBmwschema ).[1]

Common value

Many installers set the database table prefix "$wgDBprefix" to "mw_" by default.[2][3][4]

File:OOjs UI icon alert-destructive.svg <translate> Caution:</translate>
  • <translate> Do not change <tvar name=1>$wgDBmwschema</tvar> after <tvar name=2>Setup.php </tvar> has been included.</translate> <translate> Note:</translate> <translate> <tvar name=1>Setup.php </tvar> initializes various paths, includes some common files, starts sessions, and performs various other setup tasks for a request.</translate> <translate> It is not related to the installation or setup of MediaWiki.</translate>
  • <translate> Only files in <tvar name=1>includes/db/</tvar> should use <tvar name=2>$wgDBmwschema</tvar>, while everything else should use the <tvar name=3>dbSchema()</tvar> method provided by the <tvar name=4>Wikimedia\Rdbms\IDatabase</tvar> interface or extract it from the <tvar name=5>getDomainId()</tvar> method in either the <tvar name=6>Wikimedia\Rdbms\ILoadBalancer</tvar> or the <tvar name=7>Wikimedia\Rdbms\ILBFactory</tvar> interface.</translate> <translate> The <tvar name=1>DatabaseDomain</tvar> class can extract such components from a database domain ID.</translate>
  • <translate> If you configure <tvar name=1>$wgDBservers</tvar> or <tvar name=2>$wgLBFactoryConf</tvar>, you still need to define <tvar name=3>$wgDBname</tvar>, <tvar name=4>$wgDBmwschema</tvar> (if applicable for the DB type), and <tvar name=5>$wgDBprefix</tvar> (if applicable for the DB type).</translate> <translate> The combination of <tvar name=1>$wgDBname</tvar>, <tvar name=2>$wgDBmwschema</tvar>, and <tvar name=3>$wgDBprefix</tvar> define the current wiki's database domain.</translate> <translate> This is also called the local database domain.</translate> <translate> The '<tvar name=1>dbname</tvar>' and '<tvar name=2>tablePrefix</tvar>' settings in <tvar name=3>$wgDBservers</tvar> and <tvar name=4>$wgLBFactoryConf</tvar> only define the default DB/prefix when a connection is requested with <tvar name=5>DatabaseDomain::newUnspecified()->getId()</tvar> (the empty string) as the database domain, e.g. <tvar name=6>wfGetDB( DB_REPLICA, [], '' )</tvar>.</translate> <translate> Note that functions calls like <tvar name=1>wfGetDB( DB_REPLICA )</tvar>, which simply omit the database domain, are assumed to refer to the local database domain.</translate>

References


See also