Joomla Password Reset


If you forget your Joomla (version 1.5 and above) super admin password and you have access to the local machine you can run the following PERL script to reset it. Note, if you have changed the default name of the super admin (which you should always do and the id) then you will have to change the SQL update WHERE clause to the appropriate value. The code is quite verbose: meaning anybody with a little PERL can modify it to include changing the super admins username.

#!/usr/bin/perl

use DBI;

if ($#ARGV != 3) {
  print “\nUsage: jmlpasswd.pl dbname prefix dbuser dbpasswd\n”;
  exit;
}

my $dbname = $ARGV[0];
my $jml_prefix = $ARGV[1] . ‘_users’;
my $dbuser = $ARGV[2];
my $dbpasswd = $ARGV[3];

my $dbh = DBI->connect(“DBI:mysql:$dbname”, $dbuser, $dbpasswd, {RaiseError=>1})
  or die “Couldn’t connect to database: ” . DBI->errstr;

print “Enter new password: “;

my $name = <STDIN>;;
chomp($name);

my $sql=”UPDATE $jml_prefix SET PASSWORD=MD5(‘$name’) WHERE username=’admin’”;
#’admin’ is the joomla default user name
my $qu = $dbh->prepare($sql)
  or die “Prepared failed: ” . $dbh->errstr;

$affected = $qu->execute or die ‘Execute failed: ‘ . $dbh->errstr;
die “$dbh->errstr” if (!affected); # trap errors
die “No rows updated” if ($affected eq ’0E0′);

print “Joomla admin password changed!\n”;

$qu -> finish();
$dbh->disconnect();

Leave a comment