Sometimes, you might forget or lose the password to the account with the Jira administrator or Jira System Administrator permission, and you cannot retrieve it using the password reset option. For example, suppose Jira does not have an SMTP server configured, or you restored Jira from a data dump and do not know the account and/or password. In these cases, you need to reset the administrator password directly in the database.
Resetting the Jira administrator password
Getting ready
As we will reset the password stored in Jira's database, make sure you do the following:
- Connect to the Jira database via either the command line or a GUI.
- Update the Jira database records.
How to do it...
Let's assume we use the default mysql command-line tool and MySQL as the backend database for Jira. If you are using a different database, you may need to change the following SQL statements accordingly:
- Connect to the Jira database with a client tool by running the mysql -u jirauser -p command, where jirauser is the username used by Jira to access the Jira database.
- You can find Jira's database details from the dbconfig.xml file located in JIRA_HOME.
- Change to the Jira database by running the use jiradb command, where jiradb is the name of Jira's database.
- Determine the groups that have the Jira System Administrator global permission with the following SQL statement:
select perm_parameter from schemepermissions where PERMISSION=44;
- Find users that belong to the groups returned in the previous step by running the following SQL statement, where jira-administrators is a group returned from the previous step:
select child_name, directory_id from cwd_membership where parent_name='jira-administrators';
- Reset the user's password in the database with the following SQL statement, where admin is a user returned in the previous step:
update cwd_user set credential='uQieO/1CGMUIXXftw3ynrsaYLShI+ GTcPS4LdUGWbIusFvHPfUzD7 CZvms6yMMvA8I7FViHVEqr6Mj4pCLKAFQ==' where user_name='admin';
- Restart Jira to apply the change.
How it works...
With Jira's internal user directory, all user and group data is stored in the Jira database. The value 44 is the ID of the Jira System Administrator global permission.
If you do not know which groups or users are granted the Jira System Administrator global permission, you will first have to find this information using steps 4 and 5. Otherwise, you can skip to step 6 in order to reset the password.
Jira's user password is stored in the cwd_user table. As Jira only stores the hash value of the password, we changed the user's admin password hash to uQieO/1CGMUIXXftw3ynrsaYLShI+GTcPS4LdUGWbIusFvHPfUzD7CZvms6yMMvA8I7FViHVEqr6Mj4pCLKAFQ==, which is the UTF-8-encoded hash value of sphere.