Mysql 150 error when renaming a column

I have an old db with column characters for latin1

Now I'm trying to change all db in utf8, I made a script to change all tables in utf8 as follows:

ALTER TABLE `mytable` CHARACTER SET utf8;

and all columns:

ALTER TABLE `mytable` CHANGE `mycolumn` `mycolumn` varchar(200) CHARACTER SET utf8;

But on some columns (primary keys and restrictions, I think) I get this error:

Error on rename of './test/#sql-5028_217b96' to './test/mytable' (errno: 150)

Does anyone know how to get around this?

+5
source share
1 answer

Most likely, yours mycolumnis part of a foreign key. If so, you need to remove the constraint, then change the type for the primary / foreign key, and then add the constraint again.

+9
source

All Articles