Home > MySQL, Snippets of Code > How to dump MySQL database on WAMP

How to dump MySQL database on WAMP

Image representing Windows as depicted in Crun...

WAMP for Windows

In order to make a backup or a server transfer, you may need to dump a MySQL database into a sql file. If you try to do it through PHPMyAdmin, you may get a timeout error or an out of memory in PHP when using big databases. In WAMP server this is properly done through a program called mysqldump you will find on WAMP server binary folder. Nevertheless the best way to proceed is invoking the mysqldump application from command line of Windows, like this:

C:\wamp\bin\mysql\mysql5.5.8\bin\mysqldump -uroot -p dbname > c:\path\dbname.sql

A root password will be asked in the  prompt. Probably this password is still void after WAMP install. In that case press Return key and your sql dump file will be ready soon. Mine took several minutes  because I was dumping a 3 Gb database. With big databases be patient.

  1. 2016/09/19 at 6:05 am

    If you are connecting without a password you need to omit the -p flag from your command.
    With the latest version of wamp it should look like the following:

    $ C:\wamp\bin\mysql\mysql5.7.11\bin\mysqldump -h localhost -u root dbname > C:\path\dbname.sql

    To import the dumpfile:

    $ C:\wamp\bin\mysql\mysql5.7.11\bin\mysql -h localhost -u root dbname < C:\path\dbname.sql

  2. tambk.nt
    2012/02/05 at 6:07 am

    i use code in php:
    $command = “mysqldump -h localhost -u root -p db>db_dump.sql”;
    i found db_dump.sql but it is empty.

    then, i use mysql console:
    mysqldump -h localhost -u root -p db>db_dump.sql
    error: 1064(4200): you have an error in your sql syntax;
    can u help me?

    • 2012/02/10 at 12:54 pm

      Error 1064 is something mysql drops when you type wrong syntax. The weird thing is that you just call for a dump, no writing any syntax. I cannot help you, sorry.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: