MySQL – Import and Export Database with mysqldump

Export a database which is called Test:

mysqldump -u <username> -p Test > Test.sql

The sql file will be generated after you input the password.
 

Import a database:
1. Create a new database called Test2
2. Import the Test.sql into the Test2

mysql -u root -p Test2 < Test.sql

 

The following picture shows the above steps in shell.

 

Reference: How to Back Up and Restore a MySQL Database

2 thoughts on “MySQL – Import and Export Database with mysqldump”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.