MySQL ERROR 1005 (HY000): Can’t create table ‘Table.frm’ (errno: 150)

February 15th, 2008 by Sadri Sahraoui | Print MySQL ERROR 1005 (HY000): Can’t create table ‘Table.frm’ (errno: 150)

If you’re trying to import an sql file using symfony propel-insert-sql and you get this error :

ERROR 1005 (HY000): Can't create table 'Table.frm' (errno: 150)

check this command output it’s really helpful :

mysql>SHOW ENGINE INNODB STATUS;

it will give you the detailed explanation about the most recent innoDB foreign key error.
If you are using a mysqldump file add these commands at the top and bottom of the sql file

SET FOREIGN_KEY_CHECKS = 0; -- TOP
SET FOREIGN_KEY_CHECKS = 1; -- BOTTOM

that will disable constraints check

, ,

 

24 Comments

  1. Thanks for the post! Ya saved me some time this morning :-)

    Also, that’s a pretty cool plugin for displaying code (assuming its a plugin).

  2. brainfault

    you’re welcome ;-)
    yes, the plugin is cool you can grab it from http://wordpress.org/extend/plugins/google-syntax-highlighter

  3. Jan

    good!

    when I use solidDB ,I meet this question too.

    ^&^

  4. Tom

    Thanks for that initial post… exactly what I needed.

  5. mark

    i had sucessfully created table on mysql, but frm file the table i was create cann’t found.
    please help me..
    thanks.

  6. Dont’ forget to have the referencing field type matching the referenced field type. Foreign key field must not be too narrow or too wide compared with referenced primary key.
    Ciao!

  7. CommanderZ

    Positioning is broken in opera 9.52

  8. Vajahat Ali

    Thanks buddy for the help!!!

  9. redsonic

    Hi and thank you for this post, it helped me a lot.

    Best regards

  10. moltar

    This is genious, thanks! I spent like 3 hours trying to figure this out. I had a dup key name, from a previously created table! Wow.

  11. cwxwwwxdfvwwxwx

    well, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch ;)

  12. thesaintbug

    That was really helpful…
    thnx

  13. JJ

    Nice tip. Just what i was looking for. Also, im interested in integrating your code theme into my wordpress blog. Was it included in a theme or do you have a js script?

    Thx,
    JJ

  14. Thanks, it really helped me a lot. I’m using propel from symfony and wanted to use a part of the generated SQL, but it didn’t work work without these two commands.

  15. Tanuja

    It helped me a lot. After breaking my head on debugging I got your post and it took second to fix the “ERROR 1005 (HY000): …….(errno: 150)”. Thanks a lot

  16. Kenny

    great this helped me out too! thanks!

  17. Thanks man
    Helped a lot

  18. Markus

    I read that and found no answer for my case.
    The key behind is more simple than we might know or think that it is.
    Add a simple UNIQUE (column_name) where you know those entries are really unique.
    MySQL do not know this, so you have to identify this for the logic in mysql and all goes right !

    Chears n Beers

  19. Milind Arlekar

    Thanks man u r geniues..That solution saved lots of my work.

  20. Ken

    Thanks, this really helped me with installing the sample data for Magento.

  21. Sylvester

    Thanks brainfault.
    These bleeding edge error messages by MySQL are so helpful :-) in understanding what went wrong! But then beggars can’t be choosers !

  22. Thanks, worked like a charm. I appreciate your help.

  23. Thanks Sadri

    searching for the problem on on google, I found you tip…. great!

    /C.

  24. Thanks, it really helped me a lot. I’m using propel from symfony and wanted to use a part of the generated SQL, but it didn’t work work without these two commands. when I applied these commands, voila…. worked…

Trackbacks

Leave a Reply