开发者

ERROR 1005 (HY000) at line 156: Can't create table 'db1.testtable' (errno: 121)

开发者 https://www.devze.com 2023-04-12 22:17 出处:网络
I am restoring all databases from a mysqldump file and am getting the following error: ERROR 1005 (HY000) at line 156: Can\'t create table \'db1.testtable\' (errno: 121)

I am restoring all databases from a mysqldump file and am getting the following error:

ERROR 1005 (HY000) at line 156: Can't create table 'db1.testtable' (errno: 121)

As my SQL has been created from the mysqldump utility, I am confused how an error has appeared in the S开发者_如何学JAVAQL code!

The relevant lines in my dump.sql are:

CREATE TABLE `testtable` (
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `emailaddress` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Thanks, Jim


errno 121 means a duplicate key error. Probably the table already exists in the InnoDB internal data dictionary, though the .frm file for the table has been deleted. This is the most common reason for getting errno 121 in table creation. Another possible reason is a name conflict in a foreign key constraint name. Constraint names must be unique in a database, like table names are.

What does InnoDB print in the .err log?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号