Add SET FOREIGN_KEY_CHECKS=0;
to the beginning of uyour sql file
or
cat <(echo "SET FOREIGN_KEY_CHECKS=0;") data.sql | mysql
or
mysql --init-command="SET SESSION FOREIGN_KEY_CHECKS=0;"
You don't need to run SET FOREIGN_KEY_CHECKS=1
after as it is reset automatically after the session ends