"Temporary file write failure" when trying to change primary key in MySQL
I had the same problem, I did the following:

create table resources_with_key like resources;
alter table resources_with_key add primary key(`category_id`, `lang`, `model`, `rule`, `role_id`);
insert into resources_with_key select * from resources;