Search code examples
mysqlsqlmysql-error-1025

MySQL Error when dropping index (errno 150)


I've got problem with dropping foreign key index, I always get the same error

 ALTER TABLE `comments` DROP INDEX `id_user`  

which outputs

 1025 - Error on rename of './postuj_cz1/#sql-d834_a0c704' 
 to './postuj_cz1/comments' (errno: 150) 

The id_user on the other table is simple primary key index.

I'm using MySQL version 5.0.85


Solution

  • According to this link, the error relates to the definition of the primary key field. The error isn't about the foreign key index.

    Check the primary key for the COMMENTS table to make sure it does not have the UNSIGNED keyword while the COMMENTS.id_user foreign key had the UNSIGNED keyword. This keyword was causing the problem - inconsistent type of field.

    To fix, add the UNSIGNED keyword to the primary key definition for the COMMENTS table. Or remove the UNSIGNED keyword from the foreign key definition...