Backup and Restore Mysql Database using mysqldump Command

mysqldump is a effective tool to backup and restore mysql databases. Using mysqldump command we can backup one or many databases or tables.

You have to use command prompt[Windows users] or kernel[Linux users,MacOS] to backup databases.

Backup Mysql Database

  • Backup a single database
mysqldump -u root -p[root_mysql_password] [database_name] > [path_to_save_with_sql_extension]

mysqldump -u root -p123 test > D:/backups/test_backup.sql

  • Backup Multiple databases
mysqldump -u root -p[root_mysql_password] --databases [database_name] [database_name] .. > [path_to_save_with_sql_extension]

suppose we have two databases called test and tutorial
mysqldump -u root -p123 --databases test tutorial > D:/backups/test_tutorial.sql

  • Backup all the databases

mysqldump -u root -p[root_mysql_password] -all-databases > [path_to_save_with_sql_extension]

  • Backup a specific table 
Suppose we have a demo table in test database.

mysqldump -u root -p123 test demo \ > D:/backups/demotables.sql

Restore Mysql Database

To restore mysql database use following command.

mysql -u root -p[root_mysql_password] [database_name] < D:/backups/test.sql

These can be useful for backup and restore mysql databases.


  1. does this commands use for all mysql version on windows.

  2. i have this error using sql restore..

    'mysql' is not recognized as an internal or external command,
    operable program or batch file.

    help me.
    tnx u


  3. Nice Article !
    This is my pleasure to read your article.
    Really this will help to people of MySQL Community.

    I have also prepared one article about, perform backup and restore MySQL database using mysqldump tool.
    You can also visit my article, your comments and reviews are most welcome.