This Joomla tutorial will guide you on how to use SQL query through phpMyAdmin to safely change your administrator ID while at the same time maintaining your new ID association to your existing articles and Super User privilege. By using this method, you don’t have to create additional administrator account and no need to manually update every article to change its ownership to the new administrator account.
During my research and reading multiple articles regarding joomla safety especially the Joomla Security Checklist pages
, among the basic advices is to change your default username from default ‘admin’. Changing your username is good enough but it would be better is you can change your administrator ID also. It is generally know that for Joomla version 1.5, default admin ID would be 62 or 63. For Joomla version 1.7 and above(including Joomla 2.5), the ID would be 42 or 43.
After changing your administrator ID to a more unobvious value, jooomla users will found out that the new administrator ID does not linked to the article created by previous ID and have their privilege set to default level. That’s because the articles and usergroup still retained the record of previous owner ID, they doesn’t update automatically. It will be tons of workload if you update the articles owenership or ‘Created by’ manually supposedly you has more than 20 pages of articles.
Here are the overall steps you will need to do in this tutorial to properly complete your username ID changes.
1. Change your existing administrator username (skip this if you have done so)
2. Change your username ID
3. Restore your Super User privilege
4. Update/transfer articles ownership
1. Change your existing administrator username
You can just do this through your Joomla backend or administrator panel. Change the default username of ‘admin’ to other value as you wish.
2. Change your user ID
First, login to your cPanel and go to your phpMyAdmin. Select your database name which you have created during your Joomla installation. By now, you are accessing your database which is used specifically for your JOOMLA website. You’ll see list of tables on the left column, look for ‘xswlc_users’ (where ‘xswlc_’ is your database prefix) and click on it.
In simple form, this is what we do:
WampServer2>PHPMyadmin>select database>select specific table
There are 2 ways to change your user ID here - either through manual change or executing SQL query.
a. Manual change
After you have selected ‘xswlc_users’, you can see list of all users registered in your website. Search for your username and once you found it, click on ‘Edit’ to update the information.
You’ll be directed to new page where you can update your ID. Change the ID in the ‘user_id’ box. Then click on the ‘Go’ button on the bottom right. That’s it, you have successfully change your user ID!
b. SQL query
After you have selected ‘xswlc_users’, go to ‘SQL’ tab and click on it. Then, click on ‘Clear’ button to clear existing query there. Insert this SQL script just like the sample provided (change according to your own setting) and then click on ‘Go’ button at the bottom right of the form. That it, you’re done!
UPDATE `xswlc_users` SET `id`=777 WHERE `id`=62
Note: 777 is your new user ID while 62 is your previous ID. ‘Xswlc_users’ is the table you are updating.
If the query is successful, a notice will be previewed to inform you. To confirm that the change take place, you can click on the table ‘xswlc_users’ again. You will notice that the ID for your username has been changed/updated.
3. Restore your Super User privilege
In the previous step, you only change the ID. If you are trying to log into your account right now, you won’t be able to do so because of new ID is not registered in usergroup map. To grant Super User privilege to new ID you have created above, let’s go back to your phpMyAdmin panel.
Look for ‘xswlc_user_usergroup_map’ and click on it. As you can see, the values inside the table still reflect the old setting. You can also do it in 2 ways:
a. Manual edit
Now, click ‘Edit’, change ‘user_id’ value to your new ID (777). Keep ‘group_id’ as is. Value ‘8’ refers to Super User privilege. Click on any ‘Go’ button and you’re done.
b. SQL query
You can use this SQL query to update update your username privilege setting:
UPDATE `xswlc_user_usergroup_map` SET `user_id` = '777' WHERE `user_id` =62
By now, you should be able to login using your current username and password.
4. Update/transfer article ownership to your new ID
This step is optional but some webmasters would prefer to make sure everything should be as it was. If you log into your administrator account, you will notice that all article will have their ‘Created by’ column empty. Furthermore, if you go back to phpMyAdmin in ‘xswlc_content’ table, the ‘created_by’ column still refer to your old ID (62) or sometime, weird '999' user registered in the column.
Just use SQL query to update the table. This should be the fastest solution or should you prefer to update them manually through your administrator panel, it’s up to you.
UPDATE `xswlc_content` SET `created_by`=777 WHERE `created_by`=62
Note: 777 is your new user ID while 42 is your previous ID. ‘Xswlc_content’ is the table you are updating.
Changing your username should be fine but taking extra measures to change your ID and related database values are commendable. This method does not involve any form of extra installation of any scripts or extensions. Please make sure that you have backup your site prior performing change.
People in this conversation