mysql - Alter table throw error #1005 -
i have 2 different table follows
apis users
here users
table has api_id
forien key.
now executing following query thorwing error (stating api_id
column references id
column on apis
table.)
alter table `users` add constraint users_api_id_foreign foreign key (`api_id`) references `apis` (`id`) on delete cascade on update cascade
error: #1005 - can't create table 'xxxxx.#sql-54ef_229ff39' (errno: 150) (<a href="server_engines.php?engine=innodb&page=status&token=50174b3c687a6edcb259e10dd65ca6d7">details...</a>)
mysql version (development server)
server version: 5.5.42-37.1-log
the same query working in localhost
server version: 5.5.44-0ubuntu0.14.04.1 - (ubuntu)
how can fix error? in advance.
apis table
users table
sometimes problem caused if have data in table. in case if have data in users
table first truncate users table , try again.
Comments
Post a Comment