Navicat MYSQL 建立关联表 保存时遇到 cannot add foreign key constraint

首先建立user表,如下图

 然后建立message表,userid用作外键,关联user表的id

 点击上面的外键按钮,添加外键如下

 结果保存时报错: cannot add foreign key constraint

 最后查找发现user表中的id和message表中的userid定义的属性不一样,如下,一个选择了无符号,一个没选,两个选一样的,按照上面添加外键的方法就解决问题了:

原文地址:https://www.cnblogs.com/greenteaone/p/11678467.html