Wednesday, December 8, 2010

Importing large databases into Wamp

You can use tools such as bigdump to import large databases as phpmyadmin will only accept relatively small databases to import, but I prefer this on a localhost install as you already have easy access already and its quick and easy to do.

Download your database from your live site (if that's the one you want to use). Extract the .gz so you have just a .sql file.

For this example (remember yours will be different) , you need the following...

The root users name and password (for mysql) , its normally just "root" and no password.

The name of the new blank database (if you have not already created one, visit your localhost phpmyadmin and create a new blank database now)

Use windows explorer or a command prompt. Navigate your way to the folder where wamp is installed. You need to go into the folder where mysql.exe is. In my case it is D:\_DEV\bin\mysql\mysql5.1.30\bin . Most cases it will be c:\program files\wamp\bin\mysql\mysql version\bin etc...

Copy the .sql file into here. It must be in the same directory as mysql.exe

Open a command prompt in this directory if you have not already. If you have the "command prompt here" powertoy, this can be quicker than having to navigate via a command prompt to here. You can download this from Microsoft if you want it. Failing that, simply navigate your way to the appropriate directory using cd.

For this example, the database I am importing is called mybackup.sql and the new empty database I created is called test

Assuming you do NOT have a root password, type in the following...

mysql.exe -u root test < mybackup.sql


This may take a few minutes depending on the database size and your CPU power, your firewall may prompt you so you will have to allow temporary access (should only be mysql wanting localhost access)

When its finished, remove the mybackup.sql file you put in that directory.

Done :D

As an extra note, if you have a root password for mysql, you will need to use this instead (changing pass for the password)

mysql.exe -u root -p pass test < mybackup.sql