Resolve the ERROR 1005 solution for creating foreign keys in MySQL

  • 2020-05-24 06:21:19
  • OfStack

ERROR 1005 (HY000): Can't create table 'db_qxztc.qx_userssssnew' (errno: 150) It doesn't do anything to solve the problem.

To see the error detail, use the command :(found when searching for "errno 150" in MySQL Manual)

SHOW ENGINE INNODB STATUS; // for databases that use INNODB storage

In the message, 1 group [LATEST FOREIGN KEY ERROR] will have a detailed description of the latest error and the solution.
Such as:
111211 12:49:34 Error in foreign key constraint of table db_qxztc/qx_userssssnew
:
foreign key(`SSSSID`) references`qx_SSSS`(`SSSSID`)):
Syntax error close to:
`qx_SSSS`(`SSSSID`))

Hint in 'qx_SSSS' (' SSSSID ') near the syntax error, you should carefully check, I made a mistake here is references and its parameters, the lack of space.


Related articles: