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

Published:

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

  1. SSH into the system where MediaWiki is installed and find its location. It was /var/www/html/foowiki in our case.
  2. Open LocalSettings.php and everything should be under the heading ## Database settings

📝 This can of course be skipped if you already know how to access your mediawiki database, but I didn't. 🙂

Promote user

  1. Connect with a mysql client.
mysql -h localhost -u wikiuser -p wikidb
  1. Find the user id.
select user_id, convert(user_name using utf8) from `user`;
  1. 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.