[ACCEPTED]-#1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)-mysql-error-1025
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.
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`;
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.
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)
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.
SHOW CREATE TABLE alarm;
Look for theCONSTRAINT `server_id_refs_id_34554433` FORIEGN KEY (`server_id`) REFERENCES `server` (`id`)
line.ALTER TABLE `alarm` DROP FOREIGN KEY `server_id_refs_id_34554433`;
ALTER TABLE `alarm` DROP `server_id`
This will delete the 1 foreign key server from the Alarms table.
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
Hope 1 that works!
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
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.