There are few ways through which you can reset the user account’s password in MediaWiki. The first method is by using changePassword.php maintenance script – the administrator can reset the password and communicate the same to the user. The second method is by logging-into the database server and using SQL queries to update the password. You will find detailed information regarding these methods in MediaWiki’s official support page.
Today, I’m going to tell how you can reset the password via MySQL queries.
For MediaWiki version > 1.31, below are the steps.
1. Login to MySQL server and connect to MediaWiki database.
2. The user credentials are stored in a table called ‘user‘.
Note: If you had set table-prefix (say wk, then the table would be like ‘wk_user‘)
3. Check if you have ‘$wgPasswordSalt‘ set in LocalSettings.php. In case, if you had set password salt, then your query needs salt to be specified.
UPDATE user SET user_password = CONCAT(':B:somesalt:', MD5(CONCAT('somesalt-', MD5('somepass')))) WHERE user_name = 'testuser';
4. Didn’t find ‘$wgPasswordSalt‘ in LocalSettings.php file? It means, you should execute unsalted query as below:
UPDATE user SET user_password = CONCAT(':A:', MD5('somepass')) WHERE user_name = 'testuser';
That’s it. Try logging-in with the new password and it should work.