Howto reset the phpBB admin password without phpmyadmin?

There are several good howto’s explaining how you can reset a lost phpBB admin password, but all of them use phpMyAdmin for mysql access. Since I had to do this a few days ago, I thought other might benefit from such a howto that uses only command line utilities if phpmyadmin is not available.

Identifying the MySQL user/password

Locate the config.php file under your main phpBB installation directory. If you are using the debian phpBB package then the particularity of this package is that the config.php from the installation folder /var/www/phpbb2/site/config.php just calls the real config file from /etc/phpbb2/config.php

Inside the config file identify the following information:

$dbhost       = "localhost";
$dbname       = "phpbb2";
$dbuser       = "phpbb_user";
$dbpasswd     = "phpbb_password";

Resetting the admin password

Using the above information connect to the mysql server using the mysql client command line:

mysql phpbb2 -u phpbb_user -p
Enter password: <- Enter the db password
mysql>

If you don’t know the admin username running the following mysql query will return all the admin level users in phpbb:

mysql> select * from phpbb_users where user_level = 1;

(normally there is just one such user called Admin, but depending on the install/config this can be different).

Now that we know the admin username, or if you knew it already (let’s assume it is called ‘Admin’) then just run on the mysql cli:

mysql> select * from phpbb_users where username = 'Admin';

to get the current user details (including the encrypted password, etc.).

To change the password just run:

mysql> UPDATE phpbb_users SET user_password=MD5("new_admin_pass") where username = 'Admin';

Note: another quick way to achieve the same thing is to ‘promote’ another use to admin level and use that one for the management interface:

mysql> UPDATE phpbb_users SET user_level=1 where username = 'another_admin';

If you have phpmyadmin available on your system then you can still use the above information as it should be quicker to do this from cli, but in case you prefer to use phpmyadmin just use the web interface to edit the admin record and change the password (while in the function box leave MD5).

comments powered by Disqus