This week I caused to restore a backup of a mediawiki implementation to a local VM of Mediawiki. I got sent a backup of the database and the image files, and opted to use the pre-package Bitnami Mediawiki Virtual Appliance. Standing up the VM was a relatively easy matter – but the restore of the database took me sometime to crack. I was massively assisted by the Mediawiki formums – in particular Ciencia Al Poder. Who single-handedly reinvigorated my belief in community support models, and was pivotal in getting me up and running.

The Bitnami Mediawiki VM can be downloaded as an .OVA and deployed to a virtualization platform of your choice:

1.) Record the Bitnami MediaWiki Accounts:

One thing I struggled with was locating all the login. So I’ve brought them all together here. Both the “user” and “root” accounts share the same autogenerated password that’s printed to the console at first boot.

  • To Login to the Virtual Console – username: bitnami password: bitnami
  • To Login to the MediaWiki webpage: username: user password: console screen
  • To Login to PhpAdmin: username: root password: console screen

1.) Enable SSH

Next we need to enable SSH so we can transfer files and also get a more easy to use command-line from where we can restore the database.

1.) Login as username: bitnami password: bitnami

2.) Then enable SSH with:

sudo rm -f /etc/ssh/sshd_not_to_be_run
sudo systemctl enable ssh
sudo systemctl start ssh

2.) Upgrade MediaWiki to the Latest Release

1.) From the VM console change into the install directory for Mediawiki.

cd /home/bitnami/apps/mediawiki/htdocs

2.) Next we can download the latest version of the MediaWiki software with


3.) We can then extract and overwrite the existing files with:

tar -xvzf mediawiki-1.30.0.tar.gz

4.) Once done we can delete the tar file download from

rm mediawiki-1.30.0.tar.gz

5.) We can confirm that the upgrade has been successful by browsing to http://<IP>/Special:Version

4.) Transfer .SQL file and Restore

In my case being an Apple Mac user I used Cyberduck to create a SSH connection to copy files to the VM, and I use the ssh command at the command-line (rather say the more popular Windows PuTTy utility). The database was sent to me in .gz format which need to be extracted before I could get to the .SQL dump of the previous Mediawiki database. I copied the .gz file into /home/bitnami directory.

1.) ssh into appliance with:

ssh bitnami@<IP>

2.) Change into the bitnami directory if not there already

cd /home/bitnami

3.) If neccesary ungunzip the file database:

gunzip DATABASE-vmug-wiki.sql.gz

4.) Then using the mysql command import the .SSL dump:

mysql -u root -pPASSWORDFROMCONSOLE bitnami_mediawiki < DATABASE-vmug-wiki.sql

Note: The password immediate follows the command-line switch -p without a space. This is unusual as most switches demand a space. bitnami_mediawiki is the name of the built-in database – which contains tables – the restore in this way has the effect of creating a new database, since the mysql won’t allow the overwriting of a database that already contains data. It’s a quick and simple way of both creating and new database, and restoring the contents of the .SQL dump

5.) Inspect DB for Table Prefix; Allocate User Privileges

Next we will list the databases and examine the tables inside the database itself. Then we can either create a user account or use an existing user – to then grant them the rights to the database rights to the restored database. We login in interactively with mysql with:



USE vmug-wiki;

NOTE: Here we can see each of the tables has a prefix of wiki_ this not unusual pre-package/pre-built wiki implementations

We can list the users on the system with command

SELECT User FROM mysql.user;

NOTE: The Bitnami MediaWiki virtual appliance has a built-in user called bn_mediawiki that we grant privileages to…

We can create a new user with:

CREATE USER someuser IDENTIFIED BY ‘somepassword’;


You can leave the interactive mysql session by typing exit

6. Confirming your work with PhPAdmin

PhpAdmin allows to do some of the management of the database from a web-page. One reason not to use it for the process of restoring the database – often upload limits/upload timeouts make it easier to do it all from the command-line. However, it is handy for getting a visual idea of the database configuration. In order to access the PhpAdmin web-page on Bitnami Mediawiki VM, you have to create a SSH ‘tunnel” to On the mac you can do this in a seperate terminal window with the SSH command. You must provide a password to establish the tunnel – but it will sit at the command prompt afterwards – and not establish an interactive SSH console session.

1.) Open a SSH tunnel which redirects to “”

ssh -N -L 8888: bitnami@<ip>

2.) Browse to:

3.) Login as root with password from console screen

Note: User called “someuser” is created…


7.) Modify the Database Settings in LocalSetting.php

At the SSH session we will edit the LocalSettings.php file. This file controls how the wiki software connects to the database

1.) cd /home/bitnami/apps/mediawiki/htdocs/

2.) sudo vi LocalSettings.php

3.) Press [ i ] to enter insert mode in vi

4.) Scroll down to find the #Database Settings. In here we need to change the DBnam, DBuser, DBpassword and set the DBprefix

$wgDBtype            = “mysql”;
$wgDBserver         = “localhost:3306”;
$wgDBname          = “vmug-wiki”;
$wgDBuser            = “someuser“;
$wgDBpassword    = “somepassword“;

# MySQL specific settings

$wgDBprefix         = “wiki_”;


5:) Press [ESC] to exit insert mode

6.) Type :w! to save the file

7.) Type :q! to exit vi editor

8.) Upgrade the Schema

At this stage you should system should be working – but will likely need a update the schema on the database – which is a requirement after our upgrade of the Mediawiki software we did at Step2. You cannot proceed with this step until steps 1 to 7 have been completed. It’s a good idea to add to the LocalSettings.php file the database debugging parameters

$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;

These will show “Access Denied” errors indicative of invalid permissions or bad username/password in the LocalSettings.php file. In my case the connection was successful but a schema update was pending.

1.) cd /apps/mediawiki/htdocs/maintenance

2.) Run the update utility with:

php update.php

At the end of the process the Wiki will be functional. You will need to copy images across to the VM, and also copy and enable any extensions used previously.

9.) Enable Extensions

There’s two extension to Mediawiki that I like – one improves the toolbar used to edit wiki mark-up and the other is method that allows the bulk-upload of images. I tend to write my wiki on an offline system – before transfering the wiki text and images to the live site – as it often takes me some hours, days, and weeks to write a chapter – I don’t want casual visitors seeing my work in progress. I’ve often found wiki to be quite brittle – one tiny misedit to a configuration file can bring the whole system down – so I do modifications and tests to my ‘test’ environment first.

1.) Download the WikiEditor and MsUpload using the extension distributor download page:

2.) You will see they both appear in the Top10 of extension on the right-hand side

3.) The default is download the extension which is the most recent for the most recent build of Mediwiki

4.) Using your preferred SCP utility copy the .gz files across to the extensions directory held in /home/bitnami/apps/mediawiki/htdocs/extensions

5.) Open a SSH session to the the Bitnami VM, and get into the extension directory.

6.) As there is already a “WikiEditor” directory, I will rename it before extracting each of the .gz files, but unzipping each of the extension using the tar command

mv WikiEditor WikiEditor-old
tar -xvzf WikiEditor-REL1_30-dc5f855.tar.gz
tar -xvzf MsUpload-REL1_30-7fa7edc.tar.gz

7.) Next I need to enable the extensions in the LocalSettings.php file

sudo vi /home/bitnami/apps/mediawiki/htdocs/LocalSettings.php

8.) Press [ i ] to enter insert mode in vi

9.) To the end of the file enable the extensions. I like to comment my edits to LocalSettings.php and where possible add them to the end of the file – in this way I feel I’m keep my edits/preferrences seperate from the entries that make the core application work:

# Michelle Laverick: Enabled DB Trace
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;

# Michelle Laverick: Enable Extensions
wfLoadExtension( ‘WikiEditor’ );
$wgHiddenPrefs[] = ‘usebetatoolbar’;
$wgDefaultUserOptions[‘usebetatoolbar’] = 1;

wfLoadExtension( ‘MsUpload’ );
$wgMSU_useDragDrop = true;

These changes once saved causes the new toolbar to be always present and the drag-and-drop method to upload images to be always present

10.) Other Edits to the LocalSettings.php

There were some other minor edits to do with the LocalSettings.php file as provided in the Bitnamai virtual appliance.

I needed to adjust the Sitename and MetasNameSpace variables – so when the site is visited/bookmarked a friendly name is presented, and I also needed to change the default logo that appears in the top right-hand corner.

$wgSitename = “vmWIKI”;
$wgMetaNamespace = “vmWIKI”;

## The relative URL path to the logo. Make sure you change this from the default,
## or else you’ll overwrite your logo when you upgrade!
$wgLogo = “/images/vmwiki.png”;

At this stage a full restored version of the wiki including content, extensions, sitename and logo.

I did find one of my old extensions called “mediawiki-embedvideo’ complete broke the LocalSetting.php file. I think this is a bug in the extension which doesn’t know how to intergate the original mark-up that was present in the wiki-text. One for me to research or else switch to a more recent plug-in.

11.) Restoring Login Access

It had been so long since I’d logged into the mediawiki – I could not remember my password and had not taken note of it. Previously, the wiki had been rigged to a SSO/SAML configuration using a directory service held by a not-for-profit. I had that username/password – but the local account username and password. Fortunately, with command-line root access to the Bitnami appliance this was easy to fix.

1.) Locate the administrator account(s) by navigating to http://<iP>/Special:ListUsers. Change the group filter to be “Administrators” and Click Show.

2.) This will give you the username (which is case-sensitve)

3.) Next SSH into the Bitnami appliance – and navigate to the maintainance directory:

cd home/bitnami/apps/mediawiki/htdocs/maintenance

4.) Then run the changePassword.php to change the password for the user in the database:

php changePassword.php –user=“Michelle Laverick” –password=COMPLEXPASSWORD

After doing this I was able to login and do high level management including creating users, as well modifying their privileges.

In my case the ability to turn off the creation of new users had been turned off from the MediaWIki pages. There are two ways to create new users – from the maintanance directory with the

php createAndPromote.php –bots –sysops –bureaucrat “Michelle Laverick” –password PASSWORD

or by re-enabling in the Localsettings.php the ability for users to create new accounts for themselves, and for the current administrator to grant them group membership.

# The following permissions were set based on your choice in the installer
$wgGroupPermissions[‘*’][‘createaccount’] = true;
$wgGroupPermissions[‘*’][‘edit’] = true;