[ACCEPTED]-#1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)-mysql-error-1025

Accepted answer
Score: 140

There is probably another table with a foreign 4 key referencing the primary key you are 3 trying to change.

To find out which table 2 caused the error you can run SHOW ENGINE INNODB STATUS and then look 1 at the LATEST FOREIGN KEY ERROR section.

Score: 33

As was said you need to remove the FKs before. On 1 Mysql do it like this:

ALTER TABLE `table_name` DROP FOREIGN KEY `id_name_fk`;

ALTER TABLE `table_name` DROP INDEX `id_name_fk`;
Score: 24

For those who are getting to this question 3 via google... this error can also happen 2 if you try to rename a field that is acting 1 as a foreign key.

Score: 13

To bypass this in PHPMyAdmin or with MySQL, first 6 remove the foreign key constraint before 5 renaming the attribute.

(For PHPMyAdmin 4 users: To remove FK constrains in PHPMyAdmin, select 3 the attribute then click "relation view" next 2 to "print view" in the toolbar below the 1 table structure)

Score: 5

If you are trying to delete a column which 6 is a FOREIGN KEY, you must find the correct 5 name which is not the column name. Eg: If 4 I am trying to delete the server field in 3 the Alarms table which is a foreign key 2 to the servers table.

  1. SHOW CREATE TABLE alarm; Look for the CONSTRAINT `server_id_refs_id_34554433` FORIEGN KEY (`server_id`) REFERENCES `server` (`id`) line.
  2. ALTER TABLE `alarm` DROP FOREIGN KEY `server_id_refs_id_34554433`;
  3. ALTER TABLE `alarm` DROP `server_id`

This will delete the 1 foreign key server from the Alarms table.

Score: 4

I had this problem, it is for foreign-key

Click 5 on the Relation View (like the image below) then find 4 name of the field you are going to remove 3 it, and under the Foreign key constraint (INNODB) column, just put the 2 select to nothing! Means no foreign-key

enter image description here

Hope 1 that works!

Score: 0

If you are adding a foreign key and faced 9 this error, it could be the value in the 8 child table is not present in the parent 7 table.

Let's say for the column to which 6 the foreign key has to be added has all 5 values set to 0 and the value is not available 4 in the table you are referencing it.

You 3 can set some value which is present in the 2 parent table and then adding foreign key 1 worked for me.

More Related questions