Exporting and Importing mysql databases

Exporting the Database.

In this example, we will export the ‘mydb’ database into a file called ‘mydb.sql’:

mysqldump -u root -p mydb > mydb.sql

Importing the data is just as easy but involves two steps.

The first step is to create a blank database ready to receive the data.

mysqladmin -u root -p create mydb1

Once done, all that is left is to actually import the data:

mysql -u root -p mydb1 < mydb.sql

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.