Applicable to:
- Plesk for Linux
- Plesk for Windows
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
-
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.
-
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 > Domains > example.com > Databases.
Comments
4 comments
Excellent. It worked the way it should be... Thanks Mr. Marc Lopez.
I get
Zeige Datensätze 0 - 0 (1 insgesamt, Die Abfrage dauerte 0.0006 Sekunden.)
Means: 0 (zero)
(Obsidian, Ubuntu 18.04)
What else can I do?
Hello Michael Gellner
If you have the same symptoms, there's a possibility that inconsistency you have differs.
A deeper investigation is required for such cases. I would suggest submitting a support request to Plesk or to the reseller from which the license was purchased.
I found a unique situation where I had an orphan db tied to an active domain and I could NOT delete the old db via Plesk panel (since it thought it was still in use as main db for that domain), so I ran the commands listed above.
However, when backing up the server I get this error:
Warning: Application "WordPress"
Unable to back up database #. Error: Unable to find row with id in data_bases table.
In order to fix this, you have to manually add the record of the actual main db you're using with the domain to the apsResources table to associate that db as the 'master' for that domain.
Prior to doing #6 you should run these two commands:
After doing step #7:
Please sign in to leave a comment.