Fixing MySQL Error 1005 HY000: Cannot Create Table (errno: 150)
When importing a MySQL database into Plesk or cPanel, you may encounter this error:
ERROR 1005 (HY000): Can't create table 'Table.frm' (errno: 150)
This usually occurs when MySQL is trying to create tables with foreign key constraints that reference tables not yet created, or when constraints conflict with table order or definitions. A quick fix is to temporarily disable foreign key checks during the import.
Solution: Disable Foreign Key Checks During Import
Edit your SQL dump file and add the following commands:
Add this at the very top of the SQL file:
SET FOREIGN_KEY_CHECKS = 0; -- TOP
Add this at the very bottom of the SQL file:
SET FOREIGN_KEY_CHECKS = 1; -- BOTTOM
This ensures MySQL ignores foreign key validation during the import and re-enables validation once the import is complete.
Why This Works
- MySQL enforces foreign key constraints strictly in MySQL 5.7 and 8.x.
- Table creation order in SQL dumps may not match the dependency order.
- Disabling checks allows all tables to be created without error.
If the problem persists, ensure all tables use the same engine (InnoDB) and matching column types for foreign key relationships.
Fast Windows Plesk Hosting for MySQL Databases
Enjoy reliable MySQL 5.7 and 8.x hosting on Windows Server 2022 with full phpMyAdmin access.
View Plesk Hosting →