Backup and Restore your MySQL database in Windows

Backup MySQL database using mysqldump in Windows

Use mysqldump -u username -p password database_name > databasename.sql

Normally this will work in any directory in Linux and Mac. But in Windows’ case…

1. Find the directory of mysqldump.exe

2. Open CMD (Win + R then type CMD, click OK button) and go to the directory of mysqldump utility using:

cd C:\wamp64\bin\mysql\mysql5.7.21\bin

Let’s choose our database… kenvelez_db

3. Backup database using mysqldump using:

mysqldump -u [username] -p database_name > databasename.sql

This will prompt you to enter the password (if there’s any…)

This will save the dump file in the bin folder. If you want it to be saved in a specific folder (e.g. Desktop folder), use:

mysqldump -u username -p password database_name > C:\Users\Desktop\databasename.sql

This is the Desktop folder before the dump.

After the dump:

Backup success!

Use the MySQL utility to restore your database dump to your Winhost MySQL database



      • The following command will only write the data that is in the .sql file.
      • This will not drop and create the database or truncate any of your other tables in your database.
      • The command will script all the table data in the .sql file to your Winhost (localhost) database.
    • If you have a table name present in your Winhost database that matches a table name in the .sql file, the table will be overwritten with the new data. Otherwise, the script will create a new table and populate it with the new data.

1. Open CMD (Win + R then type CMD)

2. Go to the directory that the MySQL client utility is located.

3. Import the dump of your database. Run the mysql.exe program using the following arguments.

mysql –u [username] -p -h [hostname] [databasename] < C:\[dumpfile].sql

This will prompt you to enter the password (if there’s any…) and restore your database to Winhost