---
title: "MySQL加外键报错Foreign key constraint is incorrectly formed"
author: "wangcheng"
date: "2010-04-28T15:08:17Z"
tags: []
categories: ["数据库"]
slug: "mysql-foreign-key-constraint-is-incorrectly-formed"
draft: false
lastmod: "2010-04-28T15:08:17Z"
id: 655221
url: "https://wangcheng.iteye.com/blog/655221"
---

在服务器上给MySQL中的表加外键，报错

 

SQL Error (1005): Can't create table 'xxxxx' (errno: 150) Foreign key constraint is incorrectly formed

 

检查了SQL，没错，然后发现其中一个表的引擎是MyISAM，将其改为InnoDB后，运行通过