MySQL Tutorial - Import or Export A Database



Mysqldump is a tool in which you can import and export mysql databases.

It can be used to back up a database (which I will explain later) or to move databases to another server. Always back up your information on a regular basis.

1. To Export A MySQL Database:

This example shows you how to export a database. It is a good idea to export your data often.

 
Example:
# mysqldump -uusername -ppassword database_name > filename.sql


Replace username, password and database_name with your MySQL username, password and database name.

You just created a file called 'filename.sql' which has your database information included.

2. Import A MySQL Database

Here, we import a database.


 
Example:
# mysql -uusername -ppassword database_name < filename.sql



Replace the parts in red with your own information.



LINK