Force drop mysql bypassing foreign key constraint

后端 未结 6 773
别跟我提以往
别跟我提以往 2021-01-29 18:08

I\'m trying to delete all tables from a database except one, and I end up having the following error:

Cannot delete or update a parent row: a foreign key

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-29 18:54

    Drop database exist in all versions of MySQL. But if you want to keep the table structure, here is an idea

    mysqldump --no-data --add-drop-database --add-drop-table -hHOSTNAME -uUSERNAME -p > dump.sql

    This is a program, not a mysql command

    Then, log into mysql and

    source dump.sql;

提交回复
热议问题