How to delete Jira user from database
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
It is not possible to delete a user from JIRA because the user is associated with several issues.
Cause
The user might be a reporter, assignee or commented on several issue so JIRA will not allow you to delete the user until you have removed all the user's associations.
Instead you should make use of the options available in Jira. We have implemented the Right to Erasure. This also contains the option to anonymize users, which should be always the preferred option. When anonymizing users, we’ll change or erase their personal data in: Jira Core, Jira Software, Jira Service Management, and Advanced Roadmaps for Jira. Please see our documentation on Anonymizing users for these option.
Just removing the user record without removing the associated information can lead to issues, as this will cause records that are pointing to a no longer existing user account.
Workaround
It is possible, but not recommended, to forcefully delete this user from the Database without removing the user from the associated issues
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Stop JIRA. Open the database and run the following :
Run this SQL
1 2
select * from cwd_user where user_name = 'USERNAME'; select * from app_user where lower_user_name in (select lower_user_name from cwd_user where user_name = 'USERNAME');
Replace 'USERNAME' with the affected user's username (case-sensitive).
Please take note of the id values of this user in both tables for step 4. The queries might return multiple rows if there are multiple directories with associated with the user, so you might need to take note of multiple ids.
Run this SQL to delete the cwd_user_attributes of the user
1
delete from cwd_user_attributes where user_id=####;
ℹ️ Replace #### with the id values from step 2.
Run this SQL to delete the cwd_membership of the user
1
delete from cwd_membership where child_name='USERNAME';
ℹ️ Replace 'USERNAME' with the affected user's username.
Run this SQL to delete the cwd_user of the user
1
delete from cwd_user where user_name ='USERNAME';
ℹ️ Replace 'USERNAME' with the affected user's username.
Run this SQL to delete the user from app_user
1
delete from app_user where id = ####;
ℹ️ Replace #### with the id from step 2 that you got for the app_user table.
Start JIRA
This will remove the username from all 4 tables :
cwd_user_attributes
cwd_user
cwd_membership
app_user
And therefore , removing the user completely from the JIRA Internal Directory. Please remember to restart JIRA after performing the changes from the database
Also note that In some cases, it might need Hard restart of all the nodes as rolling restart may not help.
Was this helpful?