Error 150 In Mysql
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the mysql error 1025 company Business Learn more about hiring developers or posting ads with us Stack Overflow
Mysql Error 150 Rename
Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7
Mysql Error 1064
million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL: Can't create table (errno: 150) up vote 121 down vote favorite 18 I am trying to import a .sql http://stackoverflow.com/questions/4061293/mysql-cant-create-table-errno-150 file and its failing on creating tables. Here's the query that fails: CREATE TABLE `data` ( `id` int(10) unsigned NOT NULL, `name` varchar(100) NOT NULL, `value` varchar(15) NOT NULL, UNIQUE KEY `id` (`id`,`name`), CONSTRAINT `data_ibfk_1` FOREIGN KEY (`id`) REFERENCES `keywords` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; I exported the .sql from the the same database, I dropped all the tables and now im trying to import it, why http://stackoverflow.com/questions/4061293/mysql-cant-create-table-errno-150 is it failing? MySQL: Can't create table './dbname/data.frm' (errno: 150) sql mysql phpmyadmin mysql-error-1005 share|improve this question edited Oct 31 '10 at 0:37 OMG Ponies 198k36356415 asked Oct 31 '10 at 0:24 gtilx 75421018 1 For essentially all the causes of this error, here is an exhaustive resource for what causes errno 150 (and errno 121/other foreign key errors) in MySQL. –John Smith Sep 29 '12 at 0:47 15 I've found that the columns must be identical (even the unsigned flag must match). –Justin Skiles Dec 19 '12 at 19:54 3 @JohnSmith ... where? –Charles Wood Jul 29 '13 at 17:07 3 I suggest reading this blog post that lists 10 possible causes: verysimple.com/2006/10/22/… –Mark Amery Jan 2 '14 at 13:54 1 @trejder Curses! –Charles Wood Nov 7 '14 at 17:16 | show 2 more comments 27 Answers 27 active oldest votes up vote 134 down vote accepted From the MySQL - FOREIGN KEY Constraints Documentation: If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the correct column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns Error 1005 and refers to Er
here for a quick overview of the site Help Center Detailed answers to any http://stackoverflow.com/questions/1085001/mysql-creating-table-with-fk-error-errno-150 questions you might have Meta Discuss the workings and policies http://forums.devarticles.com/mysql-development-50/mysql-foreign-key-problem-errno-150t-7704.html of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow mysql error is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL: Creating table with FK error (errno 150) up vote 16 down vote favorite 4 I've created a model with MySQL Workbench and am now attempting to install it to error 150 in a mysql server. Using File > Export > Forward Engineer SQL CREATE Script... it outputs a nice big file for me, with all the settings I ask for. I switch over to MySQL GUI Tools (the Query Browser specifically) and load up this script (note that I'm going form one official MySQL tool to another). However, when I try to actually execute this file, I get the same error over and over SQLSTATE[HY000]: General error: 1005 Can't create table './srs_dev/location.frm' (errno: 150) "OK", I say to myself, something is wrong with the location table. So I check out the definition in the output file. SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; -- ----------------------------------------------------- -- Table `state` -- ----------------------------------------------------- DROP TABLE IF EXISTS `state` ; CREATE TABLE IF NOT EXISTS `state` ( `state_id` INT NOT NULL AUTO_INCREMENT , `iso_3166_2_code` VARCHAR(2) NOT NULL , `name` VARCHAR(60) NOT NULL , PRIMARY KEY (`state_id`) ) EN