Error 1005 Mysql 5.5
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 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 is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Foreign Key, Can't create table (errno: 150) up vote 7 down vote favorite 2 I am trying to build the database and tables for my system. But I found that if I don't add the foreign key in the codes. There is no error. I've used many method try to make the codes works, but it still have error. I am using MySQL 5.5.31, and the codes here: CREATE DATABASE TOS; DROP TABLE TOS.USER CASCADE; DROP TABLE TOS.BILL_HEADER CASCADE; DROP TABLE TOS.TOY CASCADE; CREATE TABLE TOS.USER (User Char(8), Name Char(10), Type Char(1), Password Char(12), PRIMARY KEY(User)); CREATE TABLE TOS.BILL_HEADER (Bill_No Char(10), CTime DateTime, No_Of INTEGER, Cus_No Char(5), DTime DateTime, PRIMARY KEY(Bill_No)); CREATE TABLE TOS.TOY (Toy_Id Char(10), FullN Char(50), ShortN Char(20), Descrip Char(20), Price DECIMAL, Avail Char(1), Cat Char(1), PRIMARY KEY(Toy_Id)); CREATE TABLE TOS.BILL_ITEM (Bill_No Char(10), BSeq_No INTEGER, Toy_Id Char(10), OTime DateTime, Quan INT, DCondition Char(1), PRIMARY KEY(Bill_No,BSeq_No), FOREIGN KEY(Bill_No) REFERENCES TOS.Bill_Header(Bill_No), FOREIGN KEY(Toy_Id) REFERENCES TOS.TOY(Toy_Id)); Error: 1005 - Can't create table 'TOS.BILL_ITEM' (errno: 150) Any help would be greatly appreciated. mysql foreign-keys mysql-error-1005 share|improve this question asked Nov 23 '13 at 19:06 Confucius 1043310 It does appear to work if I remove the DROP statements.. sqlfiddle.com/#!2/08d1e –Michael Berkowski Nov 23 '13 at 19:10 2 Usually, err 150 is a foreign key error, due to a data type and length mismatch between the column and relation, or a missing index on the primary column. You do have all the correct types and PK indexes defined though. –Michael Berkowski Nov 23 '13 at 19:12 Could you try to remove only one of the foreign keys to narrow the problem? –Oscar P
Connectors More MySQL.com Downloads Developer Zone Section Menu: Documentation Home MySQL 5.5 Reference Manual Preface and Legal Notices General Information Installing and Upgrading MySQL Tutorial MySQL Programs MySQL Server Administration Security Backup and Recovery Optimization Language Structure Globalization Data Types Functions and Operators SQL Statement Syntax The InnoDB Storage Engine Alternative Storage Engines High Availability and Scalability Replication MySQL Cluster NDB 7.2 Partitioning Stored Programs and Views INFORMATION_SCHEMA Tables MySQL Performance Schema Connectors and APIs Extending MySQL MySQL Enterprise Edition MySQL Workbench MySQL 5.5 http://stackoverflow.com/questions/20166573/mysql-foreign-key-cant-create-table-errno-150 Frequently Asked Questions Errors, Error Codes, and Common Problems Sources of Error Information Types of Error Values Server Error Codes and Messages Client Error Codes and Messages Problems and Common Errors How to Determine What Is Causing a Problem Common Errors When Using MySQL Programs Access denied Can't connect to [local] MySQL server Lost connection to MySQL server https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html Client does not support authentication protocol Password Fails When Entered Interactively Host 'host_name' is blocked Too many connections Out of memory MySQL server has gone away Packet Too Large Communication Errors and Aborted Connections The table is full Can't create/write to file Commands out of sync Ignoring user Table 'tbl_name' doesn't exist Can't initialize character set File Not Found and Similar Errors Table-Corruption Issues Administration-Related Issues Problems with File Permissions How to Reset the Root Password What to Do If MySQL Keeps Crashing How MySQL Handles a Full Disk Where MySQL Stores Temporary Files How to Protect or Change the MySQL Unix Socket File Time Zone Problems Query-Related Issues Case Sensitivity in String Searches Problems Using DATE Columns Problems with NULL Values Problems with Column Aliases Rollback Failure for Nontransactional Tables Deleting Rows from Related Tables Solving Problems with No Matching Rows Problems with Floating-Point Values Optimizer-Related Issues Table Definition-Related Issues Problems with ALTER TABLE TEMPORARY Table Problems Known Issues in MySQL Restrictions and Limits Indexes MySQL Glossary Related Documentation My
Connectors More MySQL.com Downloads Developer Zone Section Menu: Documentation Home MySQL 5.5 Reference Manual Preface and Legal Notices General Information Installing and Upgrading https://dev.mysql.com/doc/refman/5.5/en/create-table-foreign-keys.html MySQL Tutorial MySQL Programs MySQL Server Administration Security Backup and Recovery Optimization Language Structure Globalization Data Types Functions and Operators SQL Statement Syntax Data Definition Statements ALTER https://github.com/docker/compose/issues/142 DATABASE Syntax ALTER EVENT Syntax ALTER FUNCTION Syntax ALTER LOGFILE GROUP Syntax ALTER PROCEDURE Syntax ALTER SERVER Syntax ALTER TABLE Syntax ALTER TABLE Partition Operations ALTER TABLE error 1005 Online Operations in MySQL Cluster ALTER TABLE Examples ALTER TABLESPACE Syntax ALTER VIEW Syntax CREATE DATABASE Syntax CREATE EVENT Syntax CREATE FUNCTION Syntax CREATE INDEX Syntax CREATE LOGFILE GROUP Syntax CREATE PROCEDURE and CREATE FUNCTION Syntax CREATE SERVER Syntax CREATE TABLE Syntax CREATE TABLE ... LIKE Syntax CREATE TABLE ... SELECT Syntax Using FOREIGN error 1005 mysql KEY Constraints Silent Column Specification Changes CREATE TABLESPACE Syntax CREATE TRIGGER Syntax CREATE VIEW Syntax DROP DATABASE Syntax DROP EVENT Syntax DROP FUNCTION Syntax DROP INDEX Syntax DROP LOGFILE GROUP Syntax DROP PROCEDURE and DROP FUNCTION Syntax DROP SERVER Syntax DROP TABLE Syntax DROP TABLESPACE Syntax DROP TRIGGER Syntax DROP VIEW Syntax RENAME TABLE Syntax TRUNCATE TABLE Syntax Data Manipulation Statements CALL Syntax DELETE Syntax DO Syntax HANDLER Syntax INSERT Syntax INSERT ... SELECT Syntax INSERT DELAYED Syntax INSERT ... ON DUPLICATE KEY UPDATE Syntax LOAD DATA INFILE Syntax LOAD XML Syntax REPLACE Syntax SELECT Syntax SELECT ... INTO Syntax JOIN Syntax UNION Syntax Subquery Syntax The Subquery as Scalar Operand Comparisons Using Subqueries Subqueries with ANY, IN, or SOME Subqueries with ALL Row Subqueries Subqueries with EXISTS or NOT EXISTS Correlated Subqueries Subqueries in the FROM Clause Subquery Errors Optimizing Subqueries Rewriting Subqueries as Joins UPDATE Syntax MySQL Transactional and Locking Statements START TRANSACTION, COMMIT, and ROLLBACK Syntax Statement
Sign in Pricing Blog Support Search GitHub This repository Watch 470 Star 8,310 Fork 1,266 docker/compose Code Issues 666 Pull requests 69 Projects 0 Wiki Pulse Graphs New issue Image orchardup/mysql throws "ERROR: 1005 Can't create table 'db' (errno: 13)" #142 Closed mauvm opened this Issue Mar 4, 2014 · 23 comments Projects None yet Labels kind/question Milestone No milestone Assignees No one assigned 7 participants mauvm commented Mar 4, 2014 My fig.yml: mysql: image: orchardup/mysql ports: - "3306:3306" volumes: - ./mysql:/var/lib/mysql environment: MYSQL_DATABASE: laravel And this is what I get when running fig up: $ fig up Creating figmysqltest_mysql_1... Pulling image orchardup/mysql... Attaching to figmysqltest_mysql_1 figmysqltest_mysql_1 | 140304 14:12:13 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead. figmysqltest_mysql_1 | ERROR: 1005 Can't create table 'db' (errno: 13) figmysqltest_mysql_1 | 140304 14:12:13 [ERROR] Aborting figmysqltest_mysql_1 | figmysqltest_mysql_1 | 140304 14:12:13 [Note] /usr/sbin/mysqld: Shutdown complete figmysqltest_mysql_1 | Note that I ran docker-osx destroy && docker-osx shell first. The error isn't thrown when the volume to /var/lib/mysql isn't mounted. Also running the container in the VM itself works perfectly fine, so it seems to be a bug in Fig. Any idea what might cause this? I couldn't find the reason as to why the container tries to create the db table. Docker member bfirsh commented Mar 4, 2014 The db table is an internal MySQL thing. Presumably it's having trouble writing to that directory. It's possible that Fig is expanding ./mysql to the wrong thing. What is your current working directory? Did it manage to create anything inside the mysql directory in there? mauvm commented Mar 4, 2014 It creates the ./mysql directory as expected and places an empty mysql and test folder inside it. So the new directory structure