Magento problems: General error: 1005

The exact error I kept getting was:
exception ‘Zend_Db_Statement_Exception’ with message ‘SQLSTATE[HY000]: General error: 1005 Can’t create table ‘xxx catalog_category_flat_store_1.frm’ (errno: 150)’ in xxx/lib/Zend/Db/Statement/Pdo.php:234

The solution is to execute the following statements inside phpMyAdmin:
ALTER TABLE catalog_category_entity ENGINE=INNODB
ALTER TABLE core_store ENGINE=INNODB

Don’t forget the table prefixes if you have!

If you get a similar error but another table please note that this error is related to foreign indexes and occurs most offten when you move the magento database from a server to another.

I am taking the above example, the table catalog_category_flat_store_1. This table has 2 foreign keys one to catalog_category_entity and the other .. you guessed: core_store.

that’s why I executed:
ALTER TABLE catalog_category_entity ENGINE=INNODB
ALTER TABLE core_store ENGINE=INNODB