Comments on: MySQL: Error 1005 Can’t create table (errno: 150) http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Dmitriy http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-12858 Tue, 28 Jul 2009 07:10:23 +0000 http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-12858

I had the same problem. I added index for field, but the error still was ocuring, then look at reference field and saw that have a ‘unsigned field’. Changed field on unsigned and did work well

Reply  |  Quote
]]>
By: JCCyC http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-11859 Tue, 24 Mar 2009 17:09:08 +0000 http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-11859

Man. I was burned by this just today. It turned out the integer field in one table was unsigned and, in the other, signed.

Reply  |  Quote
]]>
By: Luke http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-5146 Mon, 09 Jul 2007 23:52:40 +0000 http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-5146

Oh, btw – I updated the post with two more tips:

MySQL 5.0 creates the index on a foreign key field automatically – just like for primary key, so this issue does not occur.

Also

SHOW InnoDB STATUS

is very useful when debugging. Among other things it will let you know what was the last foreign key constraint error.

Maybe you could add these tips to your site as well. :)

Reply  |  Quote
]]>
By: Luke http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-5145 Mon, 09 Jul 2007 23:38:30 +0000 http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-5145

[quote comment=”5143″]Thanks for letting me know and hopefully it will save somebody from losing more hair![/quote]

I hope so. This is one of the least helpful error messages I ever got from MySQL. I almost gave up on having foreign key constraints on these tables.

Reply  |  Quote
]]>
By: Jason http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-5143 Mon, 09 Jul 2007 22:36:59 +0000 http://www.terminally-incoherent.com/blog/2007/07/09/mysql-error-1005-can%e2%80%99t-create-table-errno-150/#comment-5143

Thanks for stopping by – I pushed up this no-index situation to the #2 spot on my troubleshooting list and added your tip that you do have to have an index on both fields. Thanks for letting me know and hopefully it will save somebody from losing more hair!

Reply  |  Quote
]]>