Can't create FOREIGN KEY CONSTRAINT in MySQL

Viewed 10516

I created my MySQL database using phpMyAdmin 3.5.8.1deb1 in Ubuntu.

Instead of that all my tables are InnoDB, I can't add a foreign key, and this is an example:

ALTER TABLE element ADD CONSTRAINT FK_element_id_user FOREIGN KEY (id_user) REFERENCES user(id) ON DELETE SET NULL ON UPDATE CASCADE;

When I run this script I get this error :

#1005 - Can't create table 'tpw.#sql-4d8_e2' (errno: 150) (Details...)

When I click on details I get this :

InnoDB Documentation Supports transactions, row-level locking, and foreign keys

I tried to add the FK manually in the relation view

2 Answers
Related