how to reproduce:
drop table if exists `t3`; drop table if exists `t2`; drop table if exists `t1`;
create table t1 (id int primary key);
create table `t2` like `t1`; alter table `t2` add foreign key (`id`) references `t1`(`id`);
create table `t3` like `t2`;
last statement fails with
ERROR 1005 (HY000): Can't create table 'test.t3' (errno: 121)
how to reproduce:
drop table if exists `t3`;
drop table if exists `t2`;
drop table if exists `t1`;
create table t1 (id int primary key);
create table `t2` like `t1`;
alter table `t2` add foreign key (`id`) references `t1`(`id`);
create table `t3` like `t2`;
last statement fails with
ERROR 1005 (HY000): Can't create table 'test.t3' (errno: 121)