Applicable to:
- Plesk for Linux
- Plesk for Windows
Symptoms
When importing a database dump at Domains > example.com > Databases > Import Dump, the operation fails with one of the following error messages in Plesk:
PLESK_ERROR: Unable to import the example_com dump:
ERROR 1452 (23000) at line 4907226: Cannot add or update a child row: a foreign key constraint fails
PLESK_ERROR: Unable to import the example_com dump:
ERROR 1215 (HY000) at line 15: Cannot add foreign key constraint
PLESK_ERROR: Unable to import the example_com dump:
ERROR 1215 (HY000) at line 15: Cannot delete or update a parent row: a foreign key constraint fails
Cause
Incorrect database design.
Resolution
Apply one of the following solutions.
-
Open a database dump in a text editor.
-
Add the line below at the beginning of the file:
CONFIG_TEXT: SET FOREIGN_KEY_CHECKS=0;
-
Go back to Plesk and restore this dump at Domains > example.com > Databases > Import Dump.
-
Connect to the Plesk server via SSH.
-
Start MySQL:
# plesk db
-
Temporary disable foreign key checks in MySQL with the command:
MYSQL_LIN: mysql> SET GLOBAL FOREIGN_KEY_CHECKS=0;
-
Go back to Plesk and restore the database dump at Domains > example.com > Databases > Import Dump.
-
Enable foreign key checks in MySQL back:
MYSQL_LIN: mysql> SET GLOBAL FOREIGN_KEY_CHECKS=1;
-
Exit MySQL:
MYSQL_LIN: mysql> exit
Comments
0 comments
Please sign in to leave a comment.