Show pagesourceBack to top Share via Share via... Twitter LinkedIn Telegram Yammer RedditRecent ChangesSend via e-MailPrintPermalink × Table of Contents backup / restore errors 150 Cannot add or update a child row: a foreign key constraint fails MySQL / MariaDB Administration backup / restore # backup all databases mysqldump -u root -p --all-databases | gzip -9 > [backupfile.sql.gz] # backup specific DB mysqldump -u root -p --databases db1 db2 db3 | gzip -9 > [backupfile.sql.gz] # restore specific DB gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname] # import into already existing DB mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql] errors 150 Error 150 is related to foreign key relations. Receiving this error means that a foreign key was defined in the table to be altered and it cannot be dropped as its properties are still valid. (source) use databasename SET FOREIGN_KEY_CHECKS = 0; \. sqlscript.sql SET FOREIGN_KEY_CHECKS = 1; http://bugs.mysql.com/bug.php?id=16181 Cannot add or update a child row: a foreign key constraint fails Check if the charsets and collations match. Last modified: 2019-12-20 14:21