Manual:Upgrading MediaWiki

 NOTE: The canonical upgrade guide is at mw:Manual:Upgrading The information below may be partially incorrect, outdated, and/or unmaintained.

Why upgrade?
Besides profiting from newly introduced features, increased performance, better scalability and support of new techniques, keeping your systems secure is the main reason to regularly upgrade your MediaWiki installation.

Release branches older than a year have passed the end of life and are no longer supported. Such releases are also referred to as legacy, outdated and deprecated releases. Security patches for these versions may - and probably will - not be provided for such releases.

As such, no server, especially no public-facing one, should run outdated releases as they must be expected to contain unpatched security vulnerabilities.

Pre-Upgrade Tasks

 * Read the UPGRADE file included within the package, in the mediawiki-[version number] directory of the .tar file.
 * Download or backup your existing MediaWiki files
 * Download or backup your database
 * If you have modified any source files or stock templates, you will need to re-modify them. Make a note of what modifications you have installed each time you install them to make the process much easier.  You can also use a program like WinMerge, to compare old stock files with your custom files
 * Determine what route you need to take by the version number, and allocate time accordingly. The version number is constructed as such: major.minor.patchlevel - example: 1.5.3 means major version 1, minor version 5 and patch level 3.

Patch Version
Example: from 1.5.2 to 1.5.3
 * 1) Extract all the files from the new MediaWiki package
 * 2) Upload or copy the files from the extracted folder to your desired destination folder
 * 3) Delete the /config/ directory
 * 4) Note: Your LocalSettings.php file will be preserved, and your wiki should operate without interruption

If you are working on a Unix like system, you can untar the new MediaWiki package at some place, copy your old LocalSettings.php file into this directory and set a symbolic link to the directory. If your webserver searches in directory /var/www for files to display and you have installed your wiki into directory /var/www/myFirstWiki the easiest way to upgrade from 1.5.2 to 1.5.3 is the following: You only have to check that the permissions - especially on file LocalSettings.php - have been set correct. If some problems occur you simply can go back to 1.5.2 by changing the symbolic link: As long as the database layout is not changed, you now can switch between versions by setting the symbolic link.
 * 1) cd /var/www
 * 2) mv myFirstWiki mediawiki-1.5.2
 * 3) tar xvzf mediawiki-1.5.3.tar.gz
 * 4) cp mediawiki-1.5.2/LocalSettings.php mediawiki-1.5.3
 * 5) ln -s mediawiki-1.5.3 myFirstWiki
 * 1) rm myFirstWiki
 * 2) ln -s mediawiki-1.5.2 myFirstWiki

Minor Version
Example: from 1.8.x to 1.9.x

To upgrade to 1.6, see http://www.mediawiki.org/wiki/Manual:Upgrading_to_1.6.


 * approach
 * 1) Backup your Database and your Webspace. Expect your wiki to possibly have a downtime of a couple minutes while updating.
 * 2) Extract all the files from the new MediaWiki package
 * 3) Lock your database to prevent editing, even if you have copied database you need to do this.
 * 4) Upload or copy the files from the extracted folder to your desired destination folder
 * 5) Update the database-layout schema
 * 6) If you have CLI (shell-access/root-access/phpShell):
 * 7) Create AdminSettings.php in wikiroot (based on AdminSettings.sample)
 * 8) Run "php maintenance/update.php" program from the CLI
 * 9) If you dont have shell-access:
 * 10) Rename your LocalSettings.php to LocalSettings.php.bak or similar
 * 11) CHMOD the /wiki/config/ folder and contents to 777 (world writable)
 * 12) Run the installer at yoursite.com/wiki/config/ (Note: You will need your existing database name, user name, password, and MediaWiki prefix
 * 13) Copy the LocalSettings.php file from the /wiki/config/ folder to the /wiki/ folder
 * 14) Add any modifications to your new LocalSettings.php file from your old file, making sure to check the documentation for any changes to variable names
 * 15) Test your wiki
 * 16) Delete the /config/ directory

Major Version
''Example: from 1.6.3 to 2.0.1
 * 1) There has not been a significant major version release to date for upgrade

Alternative: phpShell
If shell access is not available, look at options such as phpShell, which emulates a command prompt using PHP functions. This might not work on some locked-down hosting setups.

When using such a solution, it is often desirable to skip the countdown period at the start of the script. Pass the --quick option to the update script to do so:

$ php update.php --quick

Database Backups with Shell Access
Make a backup of your database with mysqldump:
 * 1) Look over the mysqldump documentation to learn about the mysqldump options, and heed this warning about mysqldump and encoding if you're using MySQL 4.1.x.
 * 2) Use a command like this (all on one line):
 * 3) Copy your mysql dump to a temporary file:.

A suggested naming convention for  is   – for example:.

Upgrade using PHPs CLI

 * 1) Upgrade the database schema (php -cli ./maintenance/update.php)

Broken Images

 * 1) Should be fixed upon saving the next edit of the page
 * 2) Alternatively, add your username/password to AdminSettings.php and run `php rebuildImages.php`
 * 3) Alternatively, postpend "?action=purge" to the url as it is most likely viewing a cached version of the page
 * 4) After upgrading to 1.6.x and all your images are broken, unable to generate thumbnails, or are completely black, you may need to set $wgHashedUploadDirectory = true; in your LocalSettings.php file which is by default false

Upgrading to utf-8 Before Upgrading to 1.5.x
Note - This is an interpretation: Upgrading to MediaWiki 1.5.x requires a database change to utf-8 formatting. This means that characters with accents like é cannot be used for various things.


 * 1) use upgrade1_5.php from /maintenance subdir, from commandline. You must create the AdminSettings.php (from AdminSettings.sample. Also make sure that $wgUseLatin1 = true is set in LocalSettings.php at least while running upgrade1_5.php)

OR


 * 1) From the command line use iconv: iconv -f iso-8859-1 -t utf-8 iso-db.sql > utf8-db.sql
 * 2) This utf8-db.sql is database to use in the 1.5.2 upgrade. Load the database into mysql with: mysql -pmysqlpass upgradabledb < utf8-db.sql. Change your $wgDBname to upgradabledb (in LocalSettings.php)


 * You might want to also truncate the Recent Changes table to clear corrupt rows.
 * You might also want to use the rebuildImages script, or re-upload the images

OR

use MySQL

mysqldump --user=***** --password=***** --default-character-set=latin1 --skip-set-charset wikidb > dump.sql mysql --user=***** --password=***** --execute="DROP DATABASE wikidb; CREATE DATABASE wikidb CHARACTER SET utf8 COLLATE utf8_general_ci;" mysql --user=***** --password=***** --default-character-set=utf8 wikidb < dump.sql

1.4.8 to 1.5.1
FIX: > table status like '%searchindex%' > repair table searchindex; #remember to add the prefix if you added one in the install
 * Search index breaks in MySQL (mysql Ver 14.7 Distrib 4.1.13a, for pc-linux-gnu (i686) using  EditLine wrapper

I had problems with collations because my sysadmin forgot to specify the default charset when Mysql was originally installed. If you have collation problems and your columns are set to swedish please run: ALTER TABLE in_cur CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_old CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_blobs CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_archive CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_brokenlinks CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_categorylinks CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_blobs CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_hitcounter CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_image CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_imagelinks CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_interwiki CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_ipblocks CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_links CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_linkscc CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_logging CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_math CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_objectcache CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_oldimage CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_querycache CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_recentchanges CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_searchindex CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_site_stats CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_trackbacks CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_transcache CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_user CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_user_newtalk CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_user_rights CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_validate CONVERT TO character set latin1 COLLATE latin1_bin; ALTER TABLE in_watchlist CONVERT TO character set latin1 COLLATE latin1_bin;

1.4.7 to anything
I've yet to find any working way to upgrade out of this version. Has anyone had any luck, or know of any professional services that would just do the upgrade for me? 24.210.222.36 04:12, 12 March 2007 (UTC) Matt

1.4beta6 to 1.6.3
With a copy of the LocalSettings.php and a copy of the database.

In LocalSettings.php


 * Change the $IP, $wgScriptPath, $wgDBname to point to the copy.
 * Add the $wgReadOnlyFile = "";

Then


 * Run on php CLI php maintenance/upgrade1_5.php then php maintenance/update.php

The scripts take the console user to connect to the database so I gave that user full access to the MySQL database.

1.4beta5 to 1.5.2
The upgrade fails when directly installing the 1.5.2 version over the 1.4beta5. The solution for me was a two step upgrade: Note that the new tables are created as InnoDB tables, which should be activated in the MySQL configuration. Otherwise, the second step will fail.
 * upgrade from 1.4beta5 to 1.4.10
 * upgrade from 1.4.10 to 1.5.2

--Keran 15:56, 24 November 2005 (UTC)

1.2.x to 1.3.x

 * MediaWiki: entries that are not used by the software will be automatically moved to Template: entries at upgrade time
 * Pick the correct character encoding -- some languages were only available in Latin-1 on 1.2.x and are now available for Unicode as well. If you want to upgrade an existing wiki from Latin-1 to Unicode you'll have to dump the database to SQL, run it through iconv or another conversion tool, and restore it

Example: upgrade from 1.2 to 1.3

1.1.x or earlier to 1.2.x
You need to specify the *admin* database username and password to the installer in order for it to successfully upgrade the database structure. You may wish to manually change the GRANTs later.


 * If you have a very old database, you may need to manually run some of the update scripts from maintenance/archives to get up to circa November 2003 levels before the automatic updater works.

UseModWiki or old "phase 2" Wikipedia code

 * You can try using the conversion script called "importUseModWiki.php" in the maintenance folder
 * Note: This script is unmaintained. It may require tweaking and customization on a per-installation basis.  Use at your own risk.

How to use:
 * 1) Install the original MediaWiki
 * 2) Call the conversion script
 * 3) SQL statements will be output
 * 4) Copy these statements to a file and then run that using mysql
 * 5) Rebuild the links tables etc. after importing