我目前正在尝试使用MySQL Workbench的Forward Engineer向导创建我的数据库,但出现此错误:
Executing SQL script in server
ERROR: Error 1005: Can't create table 'microweb.users' (errno: 121)
CREATE TABLE IF NOT EXISTS `microweb`.`users` (
`user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`role_id` INT UNSIGNED NOT NULL ,
`username` VARCHAR(45) NOT NULL ,
`password` VARCHAR(45) NOT NULL ,
`email` VARCHAR(45) NOT NULL ,
`salt` VARCHAR(45) NOT NULL ,
`first_name` VARCHAR(45) NOT NULL ,
`middle_name` VARCHAR(45) NULL ,
`last_name` VARCHAR(45) NOT NULL ,
`address_id` INT UNSIGNED NULL ,
`registration_id` INT UNSIGNED NOT NULL ,
`active` TINYINT(1) NOT NULL ,
`banned` TINYINT(1) NOT NULL ,
PRIMARY KEY (`user_id`) ,
UNIQUE INDEX `user_id_UNIQUE` (`user_id` ASC) ,
UNIQUE INDEX `username_UNIQUE` (`username` ASC) ,
UNIQUE INDEX `email_UNIQUE` (`email` ASC) ,
UNIQUE INDEX `registration_id_UNIQUE` (`registration_id` ASC) ,
CONSTRAINT `fk_user_role`
FOREIGN KEY (`role_id` )
REFERENCES `microweb`.`roles` (`role_id` )
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_user_registration`
FOREIGN KEY (`registration_id` )
REFERENCES `microweb`.`registrations` (`registration_id` )
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
SQL script execution finished: statements: 10 succeeded, 1 failed
完整的脚本包含很多外键和 21 个表。问题是当Workbench说有10个成功时,执行后phpMyAdmin中只有2个。
如果有人需要完整的模型,请告诉我。