Plesk

Unable to remove a MSSQL from Plesk: Login ‘jdoe’ owns one or more database(s). Change the owner of the database(s) before dropping the login.

Symptoms

Unable to remove a MSSQL database example_db from Plesk > Domains > example.com > Databases:

SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot use KILL to kill your own process.


SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login 'jdoe' owns one or more database(s). Change the owner of the database(s) before dropping the login.

Cause

Security misconfiguration in the MSSQL Management Studio.

Resolution

  1. Connect to the server via RDP;

  2. Login to the MSSQL instance via SQL Management Studio;

  3. Click New Query and run the following query to change the owner of the databases to "sa" user:

    sp_MSforeachdb 'EXEC [?]..sp_changedbowner ''adminplesk'' '

  4. Log into Plesk;

  5. Go to Domains > example.com > Databases and remove the example_db database.