Thursday, May 17, 2007

Mysql5.0 database import export

Recently i faced a issue of migrating a database and its content between MySql5.0 servers.In order to migrate i need to export the database contents from one server and import it into the other from the command prompt.This is how it is done.

To export:

In the command prompt go to the bin directory of MySql5.0,and enter the following command.


mysqldump --user="username" --password="userpassword" databasename>filename.sql


If you get an error saying access denied or something like that, replace your username with the default one(root) in the above command .

Thats it , you will get a .sql file in the bin directory with the name mentioned in the command line.

To import:

In order to import , place that .sql file in the bin directory of the other MySql5.0 and enter the following command.


mysql --user="username" --password="userpassword" databasename < filename.sql


Thats it. But do remember to create a database with the name you specify in the command line.

No comments: