Apr
8
2013

How to blank all page content in MediaWiki

One of our MediaWiki clients wanted us to blank all of the content within their wiki, so they can start their annually recurring project from scratch on the same platform as last year. Here’s how we blanked all content in their MediaWiki:

  1. Access your wiki’s database administration tool (we tend to use phpMyAdmin).
  2. Ensure you’ve selected your wiki’s database.
  3. Run the following SQL command to delete all pages in your MediaWiki installation:DELETE FROM page;

As always, make sure you back up your files/database before doing something like this!

Bonus: deleting all content in a particular MediaWiki namespace

You can also delete all content in a particular MediaWiki namespace in a similar fashion. So, to delete all content in your wiki’s Talk namespace, you would run the following SQL query:

DELETE FROM page WHERE page_namespace = 1;

As a guide, page_namespace = 0 is generally the Main namespace where general MediaWiki articles reside, and page_namespace = 1 is generally your MediaWiki installation’s Talk namespace.