Sunday, January 23, 2011

Mysql Dump

In this blog I will show you how to dump a mysql database into a .sql file and also restore it later.

Info :
    Mysql Username: root
    Mysql Password: password
    Database           : mydb

Dumping to a file : Take command prompt and type
          E:\ mysqldump -u root -p mydb > mydb.sql
          Enter Password: password              
       (Note: Use your mysql username and password insted of 'root' and 'password'.)

The whole database will be dumped to a file called mydb.sql in the folder E:\

Restoring the database:  Take command prompt. (First we need to create a new empty database)
                                    
          E:\ mysql -u root -p
          Enter Password: password
          mysql> create database mynewdb;
          mysql> use mynewdb
          mysql> source E:\mydb.sql
      (Note: Change E:\mydb.sql accordingly to point to your .sql file)

THE END :)

No comments:

Post a Comment