仅在Linux上导入mysql workbench导出转储时无法创建表(错误号:121)

时间:2022-02-19 21:11:25

I created a .sql dump file by exporting my tables using MySQL Workbench on a Windows machine. If I try to import that file again on Windows, everything works fine. If I try to import that file using mysql -u user -p TABLE < dumpfile.sql, I get a Can't create table (errno:121) error.

我通过在Windows机器上使用MySQL Workbench导出我的表来创建.sql转储文件。如果我尝试在Windows上再次导入该文件,一切正常。如果我尝试使用mysql -u user -p TABLE 导入该文件,我会收到一个无法创建表(错误号:121)的错误。

The original tables were created by Hibernate. A table which causes the problem is this many-to-many relationship:

原始表是由Hibernate创建的。导致问题的表是这种多对多关系:

CREATE TABLE USER_ITEM (
  USERID int(11) NOT NULL,
  ITEMID int(11) NOT NULL,
  PRIMARY KEY (USERID,ITEMID),
  KEY FK_7ykraq12rrlicwxhjfs13re56 (ITEMID),
  CONSTRAINT FK_7ykraq12rrlicwxhjfs13re56 FOREIGN KEY (ITEMID) REFERENCES item (ID),
  CONSTRAINT FK_c8pcrsn7fey94ipgiy12g3d4e FOREIGN KEY (USERID) REFERENCES user (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

It seems like Hibernate and Workbench created an index on ITEMID which has the same foreign key as my first constraint. Why? And why causes this only a problem when importing my dump file on Linux but not on Windows using MySQL workbench? Can I just rename the first constraint's foreign key?

似乎Hibernate和Workbench在ITEMID上创建了一个索引,它与我的第一个约束具有相同的外键。为什么?为什么在Linux上导入我的转储文件而不是在使用MySQL工作台的Windows上导致这个问题?我可以重命名第一个约束的外键吗?

1 个解决方案

#1


0  

It seems that there was a problem with my database. Recreating it solved that problem.

好像我的数据库出了问题。重新创建它解决了这个问题。

#1


0  

It seems that there was a problem with my database. Recreating it solved that problem.

好像我的数据库出了问题。重新创建它解决了这个问题。