MySQL backup and restore from command line

Go to start -> Run -> write CMD, then right click on Command Prompt icon and click on Run as administrator
Navigate to the “bin” directory of your mysql

Backing up via the command line

Type the following command at the prompt replacing USERNAME and DATABASE with the one you use:

A:\xampp\mysql\bin>mysqldump -a -u USERNAME -p DATABASE > c:\FILENAME.sql

You will be prompted for your database password and then the DATABASE will be dumped to a plain-text file called FILENAME.sql.

The resulting file, FILENAME.sql, is a full backup with which you can fully restore your database in case of problems.

Restoring via the command line

Restoring from FILENAME.mysql is a three step process:

Drop the database

A:\xampp\mysql\bin>mysqladmin -u USERNAME -p drop DATABASE

Recreate the database

A:\xampp\mysql\bin>mysqladmin -u USERNAME -p create DATABASE

Import the backup data

A:\xampp\mysql\bin>mysql -u USERNAME -p DATABASE < c:\FILENAME.sql




Add a Comment

Your email address will not be published. Required fields are marked *