Mysql Database Backup

Home / Mysql Database Backup

For getting database backup in mysql we use the command mysqldump 

Use the following Syntax  for database backup

mysqldump -u {Mysql UserName} -p {databaseName} > {location where you want to save}\{Name What you want to give}.sql

Example

mysqldump -u root -p myFirstDB > C:\myFirstBackup.sql

After this command hit enter it will ask your Mysql Password Enter the password and you will successfully get the database backup

Now After getting Backup we have to use it in mysql ,So for storing this backup in mysql we use the command source

Use the Following Syntax for restore database backup

source { location of database backup file }

Example

source C:\myFirstBackup.sql

If You want to get mysql database backup using cmd in windows then use following steps

First Go to to the bin folder of your mysql using the following path

  • C:\Program Files\MySQL\MySQL Server 5.7\bin
  • Now use ALT + D
  • Now when address bar is highlighted, type cmd in the bar.
  • Now Use the same command you use above
  • mysqldump -u root -p yourdatabasename > c:/myfirstbackup.sql
  • source C:\myFirstBackup.sql

Note : while you using cmd it might be possible that you get the Access is denied error, To resolve this open cmd  via Run as administrator , now use command it will work .

 

Help Others, Please Share

About Author

Leave a Reply

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

x