Jump to content


Foreign key constraint is incorrectly formed

installation failure staff response

  • Please log in to reply
2 replies to this topic

#1 crmatch



  • Members
  • Pip
  • 1 posts

Posted 08 January 2017 - 01:38 PM

I manage my own server.


Help, I deleted my SQL databases twice, and every test passed before I tried to install short of the SSH2 extension, which I didn't know how to install.


Error installing module "users". SQL statement "ALTER TABLE `x2_calendar_permissions` ADD CONSTRAI..." failed;HY000,1005,Can't create table `sunshinb_crmx2`.`#sql-82c_1c3acd` (errno: 150 "Foreign key constraint is incorrectly formed")






#2 X2Raymond


    Advanced Member

  • Administrators
  • 972 posts
  • LocationSanta Cruz, CA

Posted 09 January 2017 - 03:11 PM

This may be due to the default table engine in use on your server. If the default storage engine is set to MyISAM, then the x2_users table may not be created using InnoDB, which is required for foreign keys. To resolve, you can either update your default storage engine, or modify the users table SQL to explicitly use InnoDB.


To set the default engine, modify your my.cnf and add:

default-storage-engine = innodb

To update the table definition, update protected/modules/users/data/install.sql and alter the end of the CREATE TABLE x2_users to read:

CREATE TABLE x2_users (
    // ...
) ENGINE InnoDB, COLLATE = utf8_general_ci;

before rerunning the installer.


Also, to get the SSH2 extension installed, you can install the php5-ssh2 and libssh2 packages if you're on Debian/Ubuntu Linux.

#3 wcsr



  • Members
  • Pip
  • 5 posts

Posted 15 March 2018 - 03:02 PM

WOW I changed PHP from 5.6 to 7.0 and it now works.


Thanks for you help.

Also tagged with one or more of these keywords: installation, failure, staff response

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users