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

MySql Password Reset

As I tend to run lots of virtual machines (Virtualbox) for the various CMS I work with (Drupal and Joomla! being the main) I have a bad tendency to forget the root password (not only for MySQL but also for the various applications I’m running). Even though I have a certain way of generating strong passwords sometimes I forget which personnal algorithm I used.

As this is my note pad, and I know you can simply yahoo it and find various solutions to the problem, this blog is my one stop shop.

  1. Step 1: shut down mysqld deamon (on arch cli) :- rc.d stop mysql
  2. Step 2: restart mysqld :- mysqld_safe –skip-grant-tables &
  3. Step 3: login to mysql :- mysql -u root -p
  4. Step 4: update the user table :- UPDATE user SET Password=PASSWORD(‘newpassd’) WHERE User=’root’;
  5. Step 5: Flush DB priviledges :- FLUSH privileges;
  6. Step 6: Exit MySql : quit;
  7. Step 7: Restart mysqld : rc.d restart mysql

The password is reset.