From TestWiki
< WikiDB
Revision as of 11:11, 10 October 2017 by HappyDog (Talk | contribs) (+ note that support is being dropped for MW < 1.16)

Jump to: navigation, search

This page describes how to install WikiDB. If you already have WikiDB installed and need to upgrade to a later version, see WikiDB/Upgrading instead.


  • MediaWiki 1.16 or above - full support.
    MediaWiki 1.7 or above - limited features.
    • Support for MediaWiki < 1.16 will be dropped as of the first release of WikiDB on or after January 1st 2018. Until that time, the following notes still apply.
    • Some features of WikiDB, most notably the ability to use the WikiDB tags within templates, are only available if you are using MediaWiki 1.16 or above.
    • Earlier versions are still supported, back to MediaWiki 1.7, but some features cannot be supported on these earlier versions due to limitations in MediaWiki. You are recommended to upgrade to the latest version of MediaWiki to enable the full functionality of WikiDB.
    • Future development will continue to support and test against all versions of MediaWiki from 1.16. Earlier versions will not be tested against, however where possible backwards-compatibility will be retained.
    • I will accept patches for any version of MediaWiki back to 1.7.
    • If you encounter any problems with a particular version of MW then please report it on the bugs page.
  • WikiDB supports the following database back-ends:
    • MySQL - Full support, well tested.
    • SQLite - Full support, not yet well tested. Please report any problems (or successes!) via the bugs page.
    • PostgreSQL - Full support, not yet well tested. Please report any problems (or successes!) via the bugs page.
  • Shell access is required for the command-line setup scripts. You can avoid this for a while by manually creating the DB tables but it will probably not possible to upgrade to later versions without being able to run these scripts.

The following instructions assume that you have already installed MediaWiki and that your wiki is fully-functional.

Step 1: Download and install the code

You can download the latest version of WikiDB as a zipped archive.

Download WikiDB Here!
or visit the file description page for a bit more information (e.g. version details, etc).

You need to extract the file into your extensions directory, which should create a WikiDB folder containing some sub-folders and the main startup script. The path to this folder should be /path/to/mediawiki/extensions/WikiDB/.

If you need to install it to a different location, you will need to adjust the path when you add the require_once() line, below, to LocalSettings.php, and you will probably need to set the MW_INSTALL_PATH environment variable in order to run the command-line maintenance scripts, but otherwise this should not cause any problems.

Step 2: Modify LocalSettings.php

Once the files are in place, you need to modify LocalSettings.php (which is where all wiki configuration settings are stored) in order to load and configure the extension.

Load the extension

To use the extension, you first need to load it. To do this, you simply need to add the following line to LocalSettings.php:


You can check that the extension is loaded properly by visiting the Special:Version page on your wiki, where it should be listed along with the correct version number.

Define table namespaces

In order for the extension to have any worthwhile effect, you need to define one or more table namespaces. Table namespaces are where your table definitions are stored, and have special properties which are different to other namespaces within the wiki (for more about the concept of namespaces see this article at In most situations only a single table namespace is required, though it is possible to define several.

To set up a table namespace, you need to first create the namespaces by adding it to $wgExtraNamespaces, so that MediaWiki knows about it (including its associated 'talk' namespace) and then you need to add it to the $wgWikiDBNamespaces array so that WikiDB knows to treat it as special.

For example, here's what you need to add to LocalSettings.php in order to create a single table namespace called Table:

$wgExtraNamespaces = array(
	100 => "Table", 
	101 => "Table_Talk",
$wgWikiDBNamespaces = array(
	100 => true,

For more information, including how to set up multiple table namespaces, see the documentation for $wgWikiDBNamespaces on the Configuration page.

Further configuration

See WikiDB/Configuration settings for further (optional) configuration options.

Step 3: Set up the database

WikiDB has an automated script to set up the database ready for use. The requirements for running the WikiDB maintenance scripts is the same as those for the standard MediaWiki maintenance scripts, i.e. you need command-line access and appropriate permissions to modify the DB schema. For more details about this see mw:Manual:Maintenance scripts.

To setup the database tables, you need to run the SetupTables script:

$ cd /path/to/mediawiki/extensions/WikiDB/maintenance
$ php SetupTables.php

For completeness, and to be absolutely sure that existing pages are parsed correctly for WikiDB data, you should also run the RebuildWikiDB script. On a large wiki, this can be very slow as it involves re-parsing all pages on the wiki. It is also relatively unlikely that existing pages contain DB data if WikiDB has not already been installed, therefore you may choose to skip this step. However, it is recommended that you run it in all cases, to make absolutely sure that WikiDB is up-to-date.

$ php RebuildWikiDB.php

For further details about the various command-line scripts provided by WikiDB, see WikiDB/Maintenance scripts.


I am getting PHP 'Strict Standards' errors (E_STRICT)

This has been fixed as of v3, r844. Please upgrade WikiDB.

My DB user doesn't have CREATE TEMPORARY TABLES permission

This has been fixed as of v3, r661. Please upgrade WikiDB.