MySQL InnoDB constraint does not work
It could be related to the value of foreign_key_checks variable. Try the following statement, and check the value:

mysql&gt; show variables like 'foreign_key_checks';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| foreign_key_checks | ON    |
+--------------------+-------+