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.

  • Dave

    You posted this today…I needed it today. Perfect synchronicity. 🙂

    • Haha, nice. Cause I actually wrote it last week and more or less accidentally discovered I had forgotten to publish it this day! Good to hear it was useful to someone else. Makes blogging worth it 😉

  • Devin

    I see where I screwed up: I put in the username instead of the userid. Durr. NB that even if you put in userid after mistakenly putting in usernames you’ll have to remove the usernames from the user_groups table to add the extra groups (it didn’t move anything else

    Just posting here in case anyone else does the same boneheaded mistake as I did.

  • lewisfrancis

    Thanks for this article, saved a bunch of time!

  • Daniel Isaksen

    Thanks for this! Digital Ocean (pre made image mediawiki’s) dont have sysop for default creation. Just saying this here for indexing the tips to Google 🙂