解决方法
使用
mysqldump(从
Thingy Ma Jig Blog开始)有一个更简单的bash单线程.
MysqLdump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP | MysqL -u[USERNAME] -p[PASSWORD] [DATABASE]
如果您收到此错误:
ERROR 1217 (23000) at line 1: Cannot delete or update a parent row: a foreign key constraint fails
请尝试以下方法:
(echo 'SET foreign_key_checks = 0;'; (MysqLdump -u[USERNAME] -p[PASSWORD] --add-drop-table --no-data [DATABASE] | grep ^DROP); echo 'SET foreign_key_checks = 1;') | \ MysqL -u[USERNAME] -p[PASSWORD] -b [DATABASE]
现在它忽略了约束.