Press "Enter" to skip to content

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
[code]mysqldump -u root -p dbname > C:dbdump1.sql[/code]
-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
[code]mysqldump -u[dbuser] -p[password] dbname > dump2.sql[/code]
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

[code]mysqldump –all-databases –single-transaction –user=root  > dump3.sql[/code]

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
[code]mysqldump –databases db1 db2–single-transaction –user=root –password &gt; dump4.sql[/code]



Leave a Reply to Alok Sah Cancel reply

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