Symptoms
-
Unable to remove a database in Plesk:
- The option Remove Database is grayed out at Plesk > Domains > example.com > Databases.
- The check-box next to the database name is grayed out and the database name contains This resource is used by the installed site application at Tools & Settings > Database Server > Databases.
-
There is no application installed at Domains > example.com > Applications.
-
Unable to change a domain for the database in Plesk > Domains > example.com > Databases, there is no option to change the domain/subdomain that is related to a database.
Cause
Database inconsistency.
Resolution
In order to fix this, the following can be done:
Click on a section to expand
Through SSH connection and CLI
-
Create a backup of the Plesk database:
-
on Linux, run the command:
# plesk db dump psa > /root/psa_backup.sql
-
on Windows Server, start a command prompt as an Administrator and run the command:
C:> plesk db dump psa > C:psa_backup.sql
-
Connect to the Plesk database:
MYSQL_LIN: plesk db
-
Find ID of the subscription to which the affected domain belongs:
MYSQL_LIN: mysql> select id from domains where name=’example.com’;
+—-+
| id |
+—-+
| 23 |
+—-+ -
Find the connection ID between an application and a database using ID from the step 4:
MYSQL_LIN: mysql> SELECT data_bases.name,apsResources.pleskId FROM `data_bases` INNER JOIN `DatabaseServers` ON data_bases.db_server_id = DatabaseServers.id LEFT JOIN `apsResources` ON apsResources.pleskId = data_bases.id AND apsResources.pleskType=”db” WHERE (dom_id = 23);
+————+———+
| name | pleskId |
+————+———+
| example_db | 17 |
+————+———+ -
Delete a connection record using
pleskId
from the step 5:MYSQL_LIN: mysql> DELETE FROM apsResources WHERE pleskType=”db” AND pleskId=17;
-
Remove the database at Plesk > Domains > example.com > Databases.
Through Plesk interface
-
Log in to Plesk
- Go to Tools and settings > Database Servers and access PhpMyAdmin
-
Create psa database dump through select psa database and clicking on the export tab and clicking on Go
-
Click SQL tab to access SQL query box
-
Find ID of the subscription to which the affected domain belongs:
MYSQL_LIN: mysql> select id from domains where name=’example.com’;
+—-+
| id |
+—-+
| 23 |
+—-+ -
Find the connection ID between an application and a database using ID from the step 4:
MYSQL_LIN: mysql> SELECT data_bases.name,apsResources.pleskId FROM `data_bases` INNER JOIN `DatabaseServers` ON data_bases.db_server_id = DatabaseServers.id LEFT JOIN `apsResources` ON apsResources.pleskId = data_bases.id AND apsResources.pleskType=”db” WHERE (dom_id = 23);
+————+———+
| name | pleskId |
+————+———+
| example_db | 17 |
+————+———+ -
Delete a connection record using
pleskId
from the step 5:MYSQL_LIN: mysql> DELETE FROM apsResources WHERE pleskType=”db” AND pleskId=17;
-
Remove the database at Plesk…