Rescue your wiki from a forgotten admin password.

If you forget any user’s password (say, your own) for your local mediawiki database like I did, you’ll probably find this helpful.

The problem:

In my case I’d forgotten the admin password for our mediawiki wiki. Although all our pages are able to be publicly edited and users could still log in and do what they needed to do, the loss of the administrator account had to be fixed pronto.

 

The solution:
Wiki uses password hashing based on the user ID so you need to do this:

  1. Find the value for user_id for the user you want:
    SELECT user_id FROM user WHERE user_name=’forgotten_user’;

    Note: wiki capitalises some of my user IDs so you might like to try a variation like this:

    SELECT user_name,user_id from user;

    And match the user_id number to the username you want.

    
    
  2. Create a new password using this user ID:
    UPDATE user SET user_password=MD5(CONCAT(‘<user id result>-‘,md5(‘newpassword’))) WHERE user_id=<user id result’>;

    Don’t forget the dash after the CONCAT. For example, if your user ID is 1, as in the case of the wiki administrator account, you’d use

    …MD5(CONCAT(‘1-‘,md5(‘newpassword’)…

That should do it!

Technorati Tags: , , ,

Advertisements

2 Responses to Rescue your wiki from a forgotten admin password.

  1. Stefan says:

    thank you for this useful tip

  2. Janos says:

    Thanks, this helped.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: