MySQL backup and restore using command prompt on windows 7,8 and 10
Mysql is right now one of the most used relational database management system used on the net, Even now CBSE had introduced it in its curriculum. But the things that is not included in the system is how to take backup and restore the database on other system using command like. So in this tutorial we covered this.
Backup mysql on Windows 7,8,10
First of all run command line in Administrator mode and locate mysql installation folder. Mysql provide backup via mysqldump command. Since Mysqldump is not automatically added in the batch file thus simply placing mysqldump command will not be recognised by the command prompt.
Mysqldump command normally stored inside the bin folder of mysql, so you are required to be in that folder in-order to use mysqldump command
#1. Locate command prompt on windows 10 and right click on command to run command prompt in Administrator mode.
#2. Type CD.. to move one folder backword.
#3. Type CD “Program Files”
#4. Type CD mysql
#5. Type CD “Mysql Serevr 5.7”
#6. Type CD Bin
Now you are inside the bin folder of mysql. In this folder your mysqldump file is store. So you are ready to take backup using mysqldump command.
Mysql backup command on windows 7,8 and 10
Syntax of backup command is
C:\> mysqldump –u[username] –p[password] [databasename] > backupfilename
C:\Program files\mysql\mysql server 5.7\bin> mysqldump.exe –uroot –pramji sakila > c:\sakila.sql
Here in this case the name of my user is “root” and the password of mysql is “ramji” . The name of my database is sakila ( which is a default mysql database on mysql server )
> ( greater than ) symbol is basically a redirection operator that takes the whole mysql database and redirecting it on c:\ drive with a same name sakila.sql
This newly created backup file is a simple file which you can check on any text editor like notepad or notepad++.
Mysql restore command on windows 10
Mysql does not support the same mysql dump command to restore the backup, instead of that it use mysql command to restore any previously taken backup.
Here is the raw syntax of mysql restore command.
Syntax of Restore command is
C:\>mysql -u[username] –p[password] [databasename] < backupfilename
C:\program files/mysql/mysql server 5.7/bin > mysql.exe –uroot -pramji sakila < c:\sakila.sql
In the above example we have taken the previously taken backup file to restore our corrupted mysql database. But the redirection is totally different this time.
Use these tricks to take mysql backup and later on restore on windows system using command prompt.