mysqldump, An easy way to restore MySQL Database

A few days ago, I have to take my database dump which is in my local system and stored in MySQL, i tried from software tool phpMyAdmin but its take too much time and cannot succeed.
so i thought to restore my database by command line and use MySQL utility “mysqldump”.
I found its very easy and in less then a minutes its take all my databases dump.

To use it traverse to mysql bin directory.
to take dump there are various parameters with this command.
for a simple use type the following command

mysqldump -u root -p dbname > C:dbdump1.sql

-u is a database user, -p is for password,  dbname is your database name, “>” this tells mysqldump command to restore given database to this path “C:dbdump1.sql”.

Another example

mysqldump -u[dbuser] -p[password] dbname > dump2.sql

Note: this give you an “Warning: Using a password on the command line interface can be insecure.”

All Database Dump:
if you want to take all of your database dump at on go, below is command

mysqldump --all-databases --single-transaction --user=root  > dump3.sql

if you have set any password for your database then include “–password=dbpassword” to the above command, this is again insecure.

Specify Databases:
include –databases <db1> <db2>, this allow you to take your specific databases dump

mysqldump --databases db1 db2--single-transaction --user=root --password &gt; dump4.sql


9 Responses to mysqldump, An easy way to restore MySQL Database

Leave a Reply

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