Saturday, July 31, 2010

SQL Errno 150 While Importing Magento Database

I was moving Magento install from one server to another, without looking at any documentation on recommended way to do that. I exported/dumped the database and imported it to the new one. The database was huge, it was taking so long that I stepped away to do other stuffs. When I came back it terminated after executing 290k queries and reported an errno 150. This indicated a problem with the foreign keys.



I marked down where the last executed query was, then I created a new SQL import file starting from the next query that would be executed to the very last query. On the top of the file I disabled foreign key checking by add the line...

SET FOREIGN _KEY_CHECKS=0;

...then at the very end of the file, I re-enable it by adding the line...

SET FOREIGN_KEY_CHECKS = 1;

The import file went on to be executed without any problem or any errno 150 reported.

No comments:

Post a Comment