My Sql Error Code 1005 Errno 121
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions mysql error code 1005. can't create table (errno 150) you might have Meta Discuss the workings and policies of this
Errno 121 Mysql Foreign Key
site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers
Sql Server Error 121
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community
Errno 121 Linux
of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up SQL - error code 1005 with error number 121 up vote 12 down vote favorite 4 I'm running the following MySQL script (trimmed down), generated automatically by MySQL Workbench and I get the following mysql error 1005 errno 150 error: Error Code: 1005 Can't create table 'regula.reservation' (errno: 121) I'm not very proficient with databases and this error is not very informative. What is the problem here? -- ----------------------------------------------------- -- Table `regula`.`Users` -- ----------------------------------------------------- DROP TABLE IF EXISTS `regula`.`Users` ; CREATE TABLE IF NOT EXISTS `regula`.`Users` ( `idUsers` INT UNSIGNED NOT NULL AUTO_INCREMENT , `name` TEXT NOT NULL , `type` TEXT NOT NULL , `pwd` TEXT NOT NULL , PRIMARY KEY (`idUsers`) , UNIQUE INDEX `idUsers_UNIQUE` (`idUsers` ASC) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `regula`.`Projects` -- ----------------------------------------------------- DROP TABLE IF EXISTS `regula`.`Projects` ; CREATE TABLE IF NOT EXISTS `regula`.`Projects` ( `idProjects` INT UNSIGNED NOT NULL AUTO_INCREMENT , `ownerId` INT UNSIGNED NOT NULL , `name` TEXT NOT NULL , `date` DATE NOT NULL , `time` TIME NOT NULL , `place` TEXT NOT NULL , `itemType` INT NOT NULL , PRIMARY KEY (`idProjects`) , UNIQUE INDEX `idProjects_UNIQUE` (`idProjects` ASC) , INDEX `ownerId` (`ownerId` ASC) , CONSTRAINT `ownerId` FOREI
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 mysql rename constraint Learn more about Stack Overflow the company Business Learn more about hiring developers mysql error 150 or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack alter table add foreign key mysql Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Mysql can't create table errno 121 up vote http://stackoverflow.com/questions/4412693/sql-error-code-1005-with-error-number-121 8 down vote favorite Why am I getting this error? I don't have any foreign keys drop table if exists t_issue; SET foreign_key_checks = 0;SET storage_engine=INNODB; CREATE TABLE `t_issue` ( `id_issue` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `fk_project` int(11) DEFAULT NULL, `subject` varchar(255) DEFAULT NULL, `estimated_due_date` date DEFAULT NULL, `due_date` date DEFAULT NULL, `done_ratio` int(11) DEFAULT NULL, `fk_status` int(11) DEFAULT NULL, `fk_assigned_to` int(11) DEFAULT NULL, `fk_owner` int(11) http://stackoverflow.com/questions/22712553/mysql-cant-create-table-errno-121 DEFAULT NULL ) ENGINE=innodb DEFAULT CHARSET=latin1 mysql share|improve this question asked Mar 28 '14 at 12:14 patentul 5342417 2 Seems to work OK for me. –Malcolm Mar 28 '14 at 12:17 It's working.What error you are facing –Nagaraj S Mar 28 '14 at 12:17 It's work fine for me –Sadikhasan Mar 28 '14 at 12:19 I changed the name of the table to t_issue1 and the query works for that, for t_issue it doesen't. However I did a "Show tables" but no table named t_issue exists. What could the problem be? –patentul Mar 28 '14 at 12:20 1 It is the same previous question from you: Mysql can't create table errno 121 –Ravinder Reddy Mar 28 '14 at 12:28 | show 4 more comments 1 Answer 1 active oldest votes up vote 22 down vote accepted Mysql can't create table errno 121 You will get this message if you are trying to add a constraint with a name that is already used somewhere else. To check constraints, use the following SQL query: SELECT constraint_name, table_name FROM information_schema.table_constraints WHERE constraint_type = 'FOREIGN KEY' AND table_schema = DATABASE() ORDER BY constraint_name; Reference: http://
errno 121 - Solution! Posted by Nimeshka Srimal Sunday, October 26, 2014 0 comments If you are working frequently with MySql databases, it is more likely that you have got this error many times. If you're reading http://bitmapcake.blogspot.com/2014/10/mysql-cant-create-table-errno-121.html this article to find how to solve this error, you are in the right place. Keep on reading to know how you will get this error and how you can solve this without getting any headaches :)For those who haven't seen this before, here is the full error message: Error 1005: Can't create table '' (errno: 121) I wanted to find an exact solution for this error and write it on my blog so sql error that it will be a reference for others as well. I referred to the MySql documentation and found this doc, and this error comes under the InnoDB errors section. So now we know this has something to do with InnoDB. Let's read the documentation a little more :)As the documentation states; 14.21.5InnoDB Error Codes The following is a nonexhaustive list of common InnoDB-specific errors that you may encounter, with information about why each sql error code occurs and how to resolve the problem. 1005 (ER_CANT_CREATE_TABLE) Cannot create table. If the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed. If the error message refers to error -1, table creation probably failed because the table includes a column name that matched the name of an internal InnoDB table. …......... This is it! The error code is 1005, but it says only about the error 150, which is a different case. I went through the comments and found some nice tips. Reason for getting Error 1005: Can't create table (errno: 121): You will get this error if you are trying to add a constraint name that is already used in somewhere else. As it turns out, you can't have two foreign key constraints with the same name. Simply that's the issue. If you are getting this error while adding a foreign key to a table, that means you have used that constraint in another table. So just make sure to change the name of your foreign key constraint and save the table. It will work nicely if you have no other conflicts. :)How to know where else you have used this constraint?You can run the following query to see where else your constraint is used. I found t