TestRail: reset admin password

By | 05/13/2019

We have a TestRail installation but suddenly lose its Admin user password.

The Reset Password says that “Email sending failed” although email was configured and users are able to get emails from the server.

Also, the log /var/www/testrail.example.com/logs/log-2019-05-13.php didn’t says anything so will reset password in another way – by update this TestRail MySQL database directly.

Create the database backup:

[simterm]

root@bttrm-testrail:/home/admin# mysqldump testrail > testrail.sql-13.05.2019.bkp

[/simterm]

Connect to the MySQL server, find TestRail database:

[simterm]

root@bttrm-testrail:/home/admin# mysql
...
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| testrail           |
+--------------------+

[/simterm]

Users and their passwords are saved in the users table:

[simterm]

MariaDB [(none)]> use testrail;
MariaDB [testrail]> desc users;
+---------------------------+--------------+------+-----+---------+----------------+
| Field                     | Type         | Null | Key | Default | Extra          |
+---------------------------+--------------+------+-----+---------+----------------+
| id                        | int(11)      | NO   | PRI | NULL    | auto_increment |
| name                      | varchar(250) | NO   |     | NULL    |                |
| email                     | varchar(250) | NO   | UNI | NULL    |                |
| is_admin                  | tinyint(1)   | NO   |     | NULL    |                |
| salt                      | varchar(250) | NO   |     | NULL    |                |
| hash                      | varchar(250) | NO   |     | NULL    |                |
| is_active                 | tinyint(1)   | NO   |     | NULL    |                |
| rememberme                | varchar(250) | NO   |     | NULL    |                |
| locale                    | varchar(250) | YES  |     | NULL    |                |
...

[/simterm]

Find the admin user:

[simterm]

MariaDB [testrail]> select id, name from users;
+----+-------------------+
| id | name              |
+----+-------------------+
|  1 | admin             |
|  2 | F15531697701961   |
...

[/simterm]

And update its password.

Set salt == xv4kregi40eyortrqy1d, hash == 3e1bb0a896b92c950a449ecb5358cb10 – this will create password “secret“, and use where ID == 1 clause:

[simterm]

MariaDB [testrail]> update users set salt = 'xv4kregi40eyortrqy1d', hash = '3e1bb0a896b92c950a449ecb5358cb10' where id = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

[/simterm]

Now you can log in useng the “secret” password and reset it to some normal value.