Mysql 一张桌子有两个外键,为什么不工作?

Mysql 一张桌子有两个外键,为什么不工作?,mysql,sql,database,foreign-keys,Mysql,Sql,Database,Foreign Keys,我的问题有点不对劲。上次我只使用一个外键创建表时,它可以工作,但现在使用两个外键时,它会抛出一个错误。我遵循DBMS类中给出的模式: 错误消息 无法添加主键约束 page\u post table: create table page_post( id int(11) unsigned zerofill not null auto_increment, post longtext not null, timestamps datetime not null, ca

我的问题有点不对劲。上次我只使用一个外键创建表时,它可以工作,但现在使用两个外键时,它会抛出一个错误。我遵循DBMS类中给出的模式:

错误消息

无法添加主键约束

page\u post table:

create table page_post(
    id int(11) unsigned zerofill not null auto_increment,
    post longtext not null,
    timestamps datetime not null,
    category_id int(2) not null,
    user_id int(7) not null,
    primary key(id),
    foreign key(user_id) references users(id),
    foreign key(category_id) references categories(id)
);
类别-按页面使用的属性

id int(2) not null auto_increment,
id int(7) not null auto_increment,
用户-按页面使用的属性

id int(2) not null auto_increment,
id int(7) not null auto_increment,

您能否包括
用户
类别
表的DDL以及您收到的确切错误消息?我已经包括:)这些id列定义为主键吗?此外,错误的确切文本将非常有用。由于@Mureinik已经询问过,您得到的确切错误消息是什么?我已经在代码上方包含了错误消息。是的,这些id列是引用表的主键。