Promoting a user to sysop when all sysops are gone on a MediaWiki installation

Working for a client who has documentation on a MediaWiki installation which was set up before we got there. Was able to create users for ourselves through the regular site, but certain things like deleting pages can only be done by sysops. None of our newly registered users are of course sysops and the only existing sysop user is from whoever installed the wiki to begin with.

Here’s how to promote a user to sysop the hackish way, directly in the database.

Find database details

Note: This can of course be skipped if you already know how to access your mediawiki database, but I didn’t 🙂
  1. SSH into the system where MediaWiki is installed and find its location.
    Was /var/www/html/foowiki in our case.

  2. Open LocalSettings.php and everything should be under the heading ## Database settings

Promote user

  1. Connect with a mysql client.
    mysql -h localhost -u wikiuser -p wikidb
  2. Find the user id.
    SELECT user_id, CONVERT(user_name USING utf8) FROM `user`;
  3. Add user id to sysop (and bureaucrat) group.
    INSERT INTO `user_groups` VALUES (uid, 'sysop'),(uid, 'bureaucrat');

The user should now be sysop, which can be double checked on the Special:ListUsers wiki page.