How to reset and change user passwords in MediaWiki
If a user has forgotten their password, there are a few ways for them to reset it. One way for a user to reset their password, or for another user to do it for that user, is to use frontend form for resetting user passwords. Another way for admins who have access to the hosting account to reset the password of any user is to execute the script changePassword.php; this is done via SSH.
If the user knows their current password and they want to change it, they can do this from their account settings.
When setting a password it's recommended to use a random string of upper and lowercase letters, numbers and symbols that's at least 8 characters long. You should also make sure that you don't use the same password on other sites, for email addresses, etc.
Reset Password Form
On the frontend of the site there's a form with which users can reset their own passwords or the passwords of other users. This is the easiest and recommended method for resetting user passwords for users who have forgotten their password.
There are a few ways you can access the form:
- Go to the login page and there use the link Forgot your password.
- Another way is to go to Tools menu on the left>Special pages button>Users and rights section on the following page>Reset password button.
- You can use the URL of the page to open it directly. You have to add Special:PasswordReset to the main URL of your site. For example, if the main URL is yourdomain.com, then open yourdomain.com/index.php/Special:PasswordReset.
The Reset password form contains only a text field for the username of the user. Type the username in it and click on the button under it. This will send to the email address associated with the username an email message containing an automatically generated temporary password. By default, that temporary password expires after 7 days. Note that at that point the user will still be able to login with the original password (if they remember it). After the user logs in with the temporary password this will automatically open a form for setting a new password for the account.
Reset Passwords with the changePassword.php Script
MediaWiki comes prepackaged with a script file for resetting user passwords. It can be used by you (or other admins who have access) to reset the passwords of users. This is done by executing the script via SSH. All HostKnox customers have free SSH access as part of their MediaWiki hosting package. For more information on how to access your account via SSH check out the tutorial on how to connect to your hosting account via SSH. You may also find useful the SSH articles in our knowledge base.
The script is labeled changePassword.php and it's in the maintenance folder of MediaWiki. The maintenance folder itself is located in the root MediaWiki folder on the account. If, for instance, MediaWiki is installed directly in the public_html directory on your account, then the path to the file in relation to that directory will be public_html/maintenance/changePassword.php. If after you log into your hosting account via SSH you change the current working directory to maintenance, then to execute the script and change the password of a user you have to execute a command like this:
php changePassword.php --user=username --password=changedpassword
Replace username with the username of the user account for which you want to change the password and changedpassword with the new password for that account. If the username consists of more than one word, put them in quotation marks. For example, if the username is Example user and you want the new password to be t9?rQ;a2, then execute the following: php changePassword.php --user="Example user" --password=t9?rQ;a2.
Note that with this method of changing passwords, the user is not notified about the password reset. So you also have to send an email to the user with the new password. Or you can use any other way that's convenient for you and the user to notify the user about the new password.
As we mentioned, the above command will work if the current working directory is changed to the one containing the script (that's the maintenance folder). Otherwise, you have to include the path to the file in the command. The current working directory can be changed with the cd command. When a HostKnox customer logs into their account via SSH, the current working directory to which they are logged is the one that contains the public_html directory as a subfolder. So assuming that MediaWiki is directly installed in public_html, then to change the current working directory to the maintenance folder you have to execute the command cd public_html/maintenance.
Change Your Password from the Account Preferences
If the user knows their current password and they want to change it, they can do this from the options for their account preferences.
After you log in, access the account preferences by clicking on the Preferences link in the upper right corner of the page. The exact location of the link depends on the particular skin, but that's usually where it's located for most skins. On the page with the account options make sure that the User profile tab is selected. There you'll find a link Change password. Clicking on it will display the form for changing your password. Type the current password in the respective field, then type the new one in the two fields provided for that and click on the Change password button. The next time you log in you have to use the new password.
The form for changing the password can also be accessed by directly opening its URL address. You have to add Special:ChangePassword to the main URL of the site. For instance, if the main URL is yourdomain.com, then you have to open yourdomain.com/index.php/Special:ChangePassword.
Keep in mind that this form can only be accessed if you're logged in.
Another article on user passwords that you may find useful:
Was this answer helpful?
- MediaWiki Skins Installation and Management
- How to disable the options for user preferences in MediaWiki
- How to change default interface messages and text in MediaWiki
- How to configure and manage user account options in MediaWiki
- How to display messages on the forms for editing and creating pages in MediaWiki