HOWTO: reset/change mediawiki password in mysql

If you are administrating a MediaWiki you will certainly run into the situation where you need to change a (forgotten) user password.

This howto assumes that you try to change the password on the DB because you know SQL and the mysql command line utility.

CHECK:

We'll connect to the DB, on a command line use:

mysql mediawiki -u root -p

Lets have a quick look at the DB structure and the existing users

SHOW tables;
DESCRIBE user;
SELECT user_id, user_name, user_password FROM user;
As you can see, mediawiki does not store plain text passwords. However the encoding is pretty simple. It uses an MD5 hash over the (numeric) user_id and the plain text password.

CHANGE:

Lets change the password of user 14 to thenewpassword

UPDATE user SET user_password=md5(concat(14,'-',md5('thenewpassword'))) where user_id=14;

(c) joachim(et)buechse.ch. This description is in the public domain.