How can I backup/dump MYSQL database with foreign key constraints?
When using MyISAM as the engine of your table, mysql will &quot;ignore&quot; the foreign key constraint and let you go on, this is for compatibility reasons throughout all mysql engines.
The recommended engine to use foreign keys is InnoDB, and honestly, for 99% of cases InnoDB is better.
You can easily change all your database to use InnoDB instead of MyISAM:

add default_storage_engine = InnoDB to /etc/mysql/my.cnf (or equivalent)

modify existing tables with alter table my_table engine=innodb

to modify all tables you can try this more complex statement:
SELECT concat_ws(' ', 'alter table', t.table_name, 'engine=innodb')
FROM information_schema.tables t
WHERE t.table_type = 'base table'
  AND t.table_schema = 'my_db'
  AND t.engine != 'innodb'



Now all your foreign keys should be respected and when you use mysqldump you will se them.