Reset User Admin Redmine

Posted on

Based on the official website of Redmine in www.redmine.org which is until this post was published in 13rd March 2016 still can be visited,  Redmine itself is defined as a flexible project management web application.

To be able to access several features in an already installed redmine which is in this case is in your local computer, we can try to access it by normally typing http://localhost/redmine. The URL is assumed when you are installing redmine in a default installation. Below is the preview of the page :

redmine-default-page

As stated before, to be able to access several features available in redmine, we have to sign in first. It can be done by clicking the Sign in link in the right top of the default page as shown below :

redmine-link-sign-in-edit

By clicking the Sign in link, we will have the login page is being displayed as follows :

redmine-login-page

Sometime when we want to access the login page itself, it ends to a condition when we cannot even access redmine so it will generate error message like “Invalid user or password” as follows :

redmine-login-page-invalid-user-or-password

Below is the steps which can be followed to restore the admin user with the following conditions :

  1. The redmine version which is used to be restored the admin user in this post is 3.2.0-1. But where are we going to see the current version of redmine which runs ?, I am going to give you an additional info on how to check the version below.

Checking the redmine version   :

  1. When you can enter the administrator page by signing in redmine login page, you can normally access : http://localhost/admin/info
  2. But in case you cannot log-in as admin through redmine login page, I can only show you how to check it in Ubuntu by running the following command :
root@hostname:~# apt-cache policy redmine
redmine:
Installed: (none)
Candidate: 3.2.0-1
Version table:
3.2.0-1 500
500 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu xenial/universe i386 Packages
root@hostname:~#
The command ‘apt-cache policy redmine’ is the one which can be used to search the redmine version. The command which is executed above can only be found in Debian Linux Distribution which is one of it is Ubuntu Linux or any operating system uses The command itself ‘apt’ stands for Advanced Packaging Tool.

Below is how we check the version of Ubuntu Linux distribution :

user@hostname:/usr/share/redmine/doc$ lsb_release -r
Release:       16.04
user@hostname:/usr/share/redmine/doc$

So, based on the above information given by executing command ‘lsb_release -r’, the version of the Ubuntu used in 16.04.

  1. Generally there is no difference in my opinion on the version of the redmine. Just to let you know if the following steps we do to restore the admin’s password is not working, perhaps you have to look around another solution based on your current redmine’s version.
  1. Access your MySQL database. You can find your redmine’s configuration database by accessing file database.yml which is located in your redmine installation. In my case, it is located in :
/usr/share/redmine

The file itself, database.yml is located within the redmine installation which is located in :

/usr/share/redmine/config/database.yml

Here is the following content inside database.yml which is describing the connection to redmine’s database :

production:
adapter: mysql2
database: redmine
host: localhost
username: root
password: "password"
encoding: utf8
development:
adapter: mysql2
database: redmine
host: localhost
username: root
password: "password"
encoding: utf8
Warning: The database defined as "test" will be erased and
re-generated from your development database when you run "rake".
Do not set this db to the same as development or production.
test:
adapter: mysql2
database: redmine
host: localhost
username: root
password: "password"
encoding: utf8

Based on the above configuration, we can see that we can access the redmine’s database by using the value of the parameters which is defined in database.yml. We have to pay attention carefully that depends on the environment state of your redmine’s installation whether it is production, development or test, it will affect the redmine’s database which is going to be accessed.

How to check your redmine’s environment ?, one way that I can figure out is by checking in your Apache Webserver’s VirtualHost configuration. It is assumed that you are using Apache Webserver as your Webserver to run redmine application. I have the configuration as follows in 000-default.conf which is located in :

/etc/apache2/sites-available/000-default.conf

Below is part of the content which is available in file 000-default.conf :

<VirtualHost *:80>
...
<Directory /var/www/html/redmine>
SetEnv SECRET_KEY_BASE ...
SetEnv RAILS_ENV development
RailsBaseURI /redmine
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>

As the context stated above, redmine is in development status. So, we have to choose the redmine’s database configuration connection for development environment status based on the configuration above as follows :

hostname           : localhost
username           : root
database name : redmine
password            : password
  1. Execute the following command to access redmine’s database via MySQL command console or you can use any MySQL editor GUI available. Below is the command line used to access redmine’s database via CLI (Command Line Interface) :
root@soulreaper:/usr/share/redmine/config# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.27-2 (Ubuntu)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use redmine;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
  1. In MySQL console line, execute the following command to change the password of admin’s redmine user. Below is the command line to perform it :
mysql> update users set hashed_password = '353e8061f2befecb6818ba0c034c632fb0bcae1b', salt ='' where login = 'admin';
Query OK, 1 row affected (0,02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql>
  1. After successfully execute the query, try to login again by using the following information :

username           : admin

password            : password

We, will be able to login successfully if nothing else happens as the following image below :

redmine-login-with-admin-password

The following image is displayed on how we have successfully log in to redmine with the above login information :

redmine-login-with-admin-password-success

Leave a Reply