MediaWiki Upgrade Procedure

I use MediaWiki as a personal note-taking, documentation and code snippet storage system. This was started as an experiment, but a wiki proved to be a decent solution for the above tasks. This is a small checklist, mainly for my own reference, to follow when upgrading MediaWiki.

Dump the wiki database

This is done so to be sure that our wiki data is safe in case anything goes wrong (very unlikely):

mysqldump -u mymysqluser -p --opt --databases mywikidb > mywikidb.sql

Or if your database is too big, you can pipe it to gzip before dumping to file:

mysqldump -u mymysqluser -p --opt --databases mywikidb | gzip -9 > mywikidb.sql.gz

How to restore the database

Just in case anything goes wrong with the upgrade procedure and you need to restore the backed up database, all you have to do is:

mysql -u mymysqluser -p mywikidb < mywikidb.sql

Backup the wiki files

Take a copy of the wiki files and directories:

cp -a wikidir wikidir.BAK

Delete old wiki files

Delete the old files and directories except:

  1. the extensions/ directory (if there are any extensions installed)
  2. the images/ directory (if there are uploaded images)
  3. the .htaccess file
  4. the AdminSettings.php file
  5. the LocalSettings.php file

Upload the new wiki files

Move the new wiki files to the the wiki directory and set proper permissions:

chmod -R u=rwX,g=-,o=rX wikidir/

Note that you might need to further protect AdminSettings.php, LocalSettings.php and any other file that contains sensitive information, by restricting access to it with proper rules inside the .htaccess file. For example:

<files ~ "^.+Settings\.php">
    Order allow,deny
    Deny from all

Upgrade the wiki database tables

Change to the maintenance/ directory and run:

php update.php

Also, it is recommended to refresh the links between the various articles inside the wiki. To do this run the refreshLinks.php script:

php refreshLinks.php

Delete the config/ directory

The config/ directory is not needed so you might want to completely delete it or restrict access to it.

Apply any code modifications

Finally, apply any custom changes to the wiki code.

MediaWiki Upgrade Procedure by George Notaras is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Copyright © 2006 - Some Rights Reserved

George Notaras avatar

About George Notaras

George Notaras is the editor of the G-Loaded Journal, a technical blog about Free and Open-Source Software. George, among other things, is an enthusiast self-taught GNU/Linux system administrator. He has created this web site to share the IT knowledge and experience he has gained over the years with other people. George primarily uses CentOS and Fedora. He has also developed some open-source software projects in his spare time.

3 responses on “MediaWiki Upgrade Procedure

  1. George Notaras Post authorPermalink →

    The above way of upgrading assumes that the hosting service provides shell access (most probably through SSH) to your account and, furthermore, access to the php interpreter from the command line. It seems that this is not possible in your case.

    There are alternative ways of upgrading, which cover your situation, but please look for them in the official Mediawiki documentation.

  2. Peter Poortinga Permalink →

    Problems running the update.php

    I am also hosting the mediawiki files on godaddy. I am trying to upgrade from 1.5 to 1.7 and am having no luck. I backed up my database, and all the wikimedia files. Then I replace all the old files with the new ones using an ftp program. The last step says to run the update.php using a command line. I am not sure what this means. Opening the command prompt on my windows machine will do nothing obviosly since the program is hosted not on my computer, but on godaddy. I have tried entering RAW commands using my FTP program to no avail. so, How do I run the update.php file located on the server? Thanks!

    A different provider, but I have the same challenge. Why is it not possible to run this update script from the godfather-role?

  3. Marc Permalink →

    Thanks for this, it was exactly what I’ve been looking for.