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 comment

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