Friday, November 10, 2006

Moving MySQL database

Question is how you move database from one computer to another?
There are various softwares available to do this e.g. MySQLFront, NaviCat etc. but they are only 30 days trial version.

Best way to do this is "mysqldump" utility provided by MySQL which requires you to type 2 lines of code. 1 line to retreive the data into sql file and another line to import the data into a new database where you want to move the data.

Following are steps in detail:
1) Go to bin directory of mysql using command prompt
2) enter following command
mysqldump -u Username -p Password DatabaseName > Filename.sql

This command will dump the data from "DatabaseName" to a file called "Filename.sql" . You can find this file inside "data" directory under mysql directory.

3) Create new database e.g. "NewDBName" whereever you want to migrate the database

4) To import the data from .sql file type following line on command prompt

mysql -u Username -p Password NewDBName < Filename.sql

Here is an example, How I transfer "NID" database to file "nid.sql" and from file "nid.sql" to a database called "nidcopy.sql"



You can also find a good tutorial online here.
http://www.theprojects.org/tutorials/mysqldump.php

0 Comments:

Post a Comment

<< Home