TIP: Changing username/password of a mediawiki user on Linux
Purpose: Some time back I wrote an article on how to setup mediawiki on your Debian Linux system. Now suppose you are the administrator of the mediawiki and one of your user sends you a request to reset his/her password. So in this tutorial we will learn how to change a user’s password using MySQL server from the command line.
Before I go ahead I would like to mention that a user himself can reset the password using “E-mail Password” option on the mediawiki login page. But let’s suppose that your mediawiki’s e-mail feature is NOT working (this is very likely) and hence the user cannot use the “E-mail Password” facility and therefore you as an administrator has to perform this task.
So let’s begin…
Step 1: Install mysql-client
Mostly likely you will have this package installed on your system. In case if you don’t have one then install it first.
apt-get install mysql-client-5.0
Step 2: Login into your mysql server
# mysql -u root -p
Your database password will be the same one which you had entered when you had installed MySQL from previous part. After entering the password you will be taken to a mysql login like this:
debian:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 460
Server version: 5.0.51a-24 (Debian)Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
Step 3: Change the password
Give the following commands on the “mysql” prompt:
mysql> show databases:
+——————–+
| Database |
+——————–+
| information_schema |
| mantis |
| mysql |
| wikidb |
| webissues |
+——————–+
5 rows in set (0.00 sec)
Here the name of my mediawiki database is wikidb. This is the same name which you had entered while configuring mediawiki.
mysql> use wikidb;
mysql > show tables;
Look for a table with name user. We are interested in this one.
Now you will need to know for which user you are going to change the password. I am assuming that I am going to change for user with user_id=2.
You can obtain the details of the user with the following command:
mysql> describe user;
mysql> select * from user;
Once you know user_id or user_name of the user for which you are going to change the password, give the following command:
mysql>UPDATE user SET user_password=md5(concat(user_id,'-',md5('mypassword'))) where user_id='2';
where:
mypassword = New password that you like to set.
user = Name of the table
user_password = Name of the field of the table “user”
user_id = User’s id number which you can obtain from “select * from user” command as shown above.
Upon successful completion of the command you should be able to see something this:
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0mysql>
Important Notes:
- The word user_id (in blue above) should be as it is. Don’t substitute the user’s id number in there.
- Also you may notice that we use a md5 function in the command. This is because mediawiki does not stores the password in cleartext, rather it runs a md5sum on the user-id and password and stores that number as the password.
- You can also change the password using the GUI-based phpmyadmin. However I was not able to figure that one out. In case if I do I will update my post.
That it. Now you can inform your user that the password has been reset to so and so and look smart!


Email Subscription









March 19th, 2009 at 3:06 pm
[...] How to change username and/or password of a mediawiki user [...]
September 22nd, 2009 at 10:12 am
[...] finden muss, hier mein ganz persönlicher Merker: Zum Glück haben sich andere schon einmal dem Problemangenommen. Jan Häußler Von [...]