Thursday, 2 February 2012

Fun when copying magento installs to local WAMP installation

Here we go again. All I want to do is some quick mods to the skin on a magento installation, so I install WAMP locally on my PC.

I do an sql dump and as usual I create a db in WAMP and go to import.

c:\wamp\bin\mysql\mysqlx.xx.xx\bin> mysql -u root <dbname>
mysql>
mysql> source <filename.sql>;

So it's failing again. It always fails. What now?
Foreign keys. Of course. Error 150. Foreign Key Constraints.
So I paste this into the top:


SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;

pretty standard fare.

Still not working. Why?

Try all sorts. Still not working.

Well guess what 2 hours has taught me. Don't use source.

This is how you import a magento sql dump:

c:\wamp\bin\mysql\mysqlx.xx.xx\bin> mysql -u root [dbname] < [filename.sql]

Then it actually uses the disable foreign key thing !!!

Why it ignores it using source I don't know.

So - great, then we get this:


ERROR 2006 (HY000) at line 6027: MySQL Server has gone away.

Fantastic.


Well the solution to this is to increase the max_allowed_packet to 10M (from 1M) in my.ini (right click your WAMP icon and go to it that way)

Worked. Finally.

Hopefully this will save someone else 2 hours of work.

No comments:

Post a Comment