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.


use DBI;

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

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>;;

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();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s