The following is a non-exhaustive list of common
InnoDB-specific errors that you may
encounter, with information about why each occurs and how to
resolve the problem.
1005 (ER_CANT_CREATE_TABLE)
Cannot create table. If the error message refers to
errno 150, table creation failed because
a foreign key constraint was not correctly formed. If the
error message refers to errno -1, table
creation probably failed because the table included a column
name that matched the name of an internal InnoDB table.
1016 (ER_CANT_OPEN_FILE)
Cannot find the InnoDB table from the
InnoDB data files, although the
.frm file for the table exists. See
Section 13.2.17.1, “Troubleshooting InnoDB Data Dictionary Operations”.
1114 (ER_RECORD_FILE_FULL)
InnoDB has run out of free space in the
tablespace. You should reconfigure the tablespace to add a
new data file.
1205 (ER_LOCK_WAIT_TIMEOUT)
Lock wait timeout expired. Transaction was rolled back.
1213 (ER_LOCK_DEADLOCK)
Transaction deadlock. You should rerun the transaction.
1216 (ER_NO_REFERENCED_ROW)
You are trying to add a row but there is no parent row, and a foreign key constraint fails. You should add the parent row first.
1217 (ER_ROW_IS_REFERENCED)
You are trying to delete a parent row that has children, and a foreign key constraint fails. You should delete the children first.

User Comments
ERROR 1005 (HY000): Can't create table './<db_name>/#sql-32be_1b99b.frm' (errno: 150)
This has always come and bit me more than once - mostly because of my own stupidity. The error message is not all that helpful in guiding you to fix the problem. Hence I thought I would document it.
You will encounter this problem typically when the tables have been created with different Engines e.g one is of the type INNODB and the other is of the type ISAM.
ERROR 1005 (HY000): Can't create table './<db_name>/#sql-32be_1b99b.frm' (errno: 150)
Other reason for that error is trying to set a forein key between two fields that are not exactly the same. The fields type, dimension and flags should be identical.
ERROR 1005 : Can't create table './<db_name>/#sql-<text>.frm' (errno: 121)
I found that this when I used the create script like option in Toad (basically use the same SQL).
I had forgotten to rename a constraint
ERROR 1005 (HY000): Can't create table './MyDB/#sql-e4a_c715.frm' (errno: 121)
As mentioned above, you will get this message if you're trying to add a constraint with a name that's already used somewhere else.
There is really not much wrong with allowing innodb to choose the name for you. Simply omit the CONSTRAINT keyword when creating foreign keys.
likewise...
ERROR 1025 (HY000): Error on rename of './MyDB/MyTable' to './MyDB/#sql2-e4a-ca3e' (errno: 152)
To avoid getting this error while trying to drop a foreign key, use the constraint name rather than the column name of the foreign key.
Summary:
99.999% of the time errors like this have nothing to do with the ability to create a temporary file and much to do with foreign key issues.
Regarding 1005:
Usually caused by an error related to a foreign key. To see a complete error description type:
Show innoDB status;
Read under the section: Latest Foreign Key Error, and there you go! Your problem explained! Just read it two or three times if you don’t get it. Trust me it helps a lot.
Add your own comment.