In addition to FFrewin's fine answer, here's a couple of alternative ways to reset the admin password.
Notice
Remember that most of these methods will set your password to something simple like admin
. It's very important to set a stronger password afterwards. If there is reason to believe the site has been hacked, you might want to remove other users with admin access once you've recovered access to your Joomla installation.
These methods are partly taken from Joomla Docs.
Alternative 1: Configuration.php file
If you are able to log in with another user (without super-admin rights), it is possible to add this line to the bottom of the configuration.php
file in your Joomla root directory:
public $root_user='myname';
Replace myname
with the username of any user you know the password of (with Author rights or higher). This user will now be able to log in as superadministrator, and you can edit/add users in the user manager. Remember to remove the extra line from your configuration.php
file when you're done, either by letting Joomla try to do it automatically when prompted, or by editing the file manually.
Alternative 2: Add new Super-admin user
A new super-administrator user can be created using this method:
Open phpMyAdmin (or similar, depending on your hosting) and select the database for the Joomla! site.
Press the "SQL" button in the toolbar to run an SQL query on the selected database. This will display a field called "Run SQL query/queries on database ".
Delete any text in this field and copy and paste the following query below and press the Go button to execute the query and add the new Administrator user to the table:
INSERT INTO `jos31_users`
(`name`, `username`, `password`, `params`)
VALUES ('Administrator2', 'admin2',
'd2064d358136996bd22421584a7cb33e:trd7TvKHx6dMeoMmBVxYmg0vuXEA4199', '');
INSERT INTO `jos31_user_usergroup_map` (`user_id`,`group_id`)
VALUES (LAST_INSERT_ID(),'8');
Remember to replace the two occurrences of jos31_
with the prefix used by your Joomla installation (this is usually easily spotted in phpMyAdmin).
You can now access your site with username admin2 and password secret. Make sure to edit your password once you've logged in.
Alternative 3:
Create a PHP file with the code below, upload it to your JOOMLAROOT/administrator directory, and run it in your browser. It will log you in instantly (both Joomla 2.5 and 3), and allow you to add/edit users. Remember to remove the file once you're done. Failure to do so will represent a huge security issue.
The tool can also be found here: http://myext.eu/en/j25-login
<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
require_once JPATH_BASE.'/includes/helper.php';
require_once JPATH_BASE.'/includes/toolbar.php';
$app = JFactory::getApplication('administrator');
JPluginHelper::importPlugin('user');
$user = JUser::getInstance();
$db = JFactory::getDBO();
$q = 'SELECT u.* FROM `#__users` as u
LEFT JOIN `#__user_usergroup_map` as ug ON u.id = ug.user_id
WHERE `block` = 0 AND `activation` = 0 AND ug.group_id = 8
LIMIT 0,1';
$db->setQuery($q);
$user_tmp = $db->loadObject();
$user_tmp->guest = 0;
$user_tmp->isRoot = 1;
// $user_tmp->groups = array(8=>8);
// $user_tmp->_authGroups = array(1,8);
// $user_tmp->_authLevels = array(1,1,2,3);
// $user_tmp->gid = 1000;
foreach($user_tmp as $k=>$v){
$user->set($k,$v);
}
$session = JFactory::getSession();
$session->set('user', $user);
$app = JFactory::getApplication();
$app->checkSession();
$app->redirect( JUri::base(), "" );