MySQL Database Import Command

The syntax is as follows to import the data created by mysqldump command:

mysql -u {DB-USER-NAME} -p {DB-NAME} < {db.file.sql} mysql -u {DB-USER-NAME} -h {MySQL-SERVER-HOST-NAME} -p {DB-NAME} < {db.file.sql}

In this example import a file called sales.sql for salesdb1 user and sales db, enter:

$ mysql -u sales -p salesdb1 < sales.sql

If database salesdb1 does not exists, first create it and than import it as follows:

$ mysql -u root -p -e 'create database salesdb1'
$ mysql -u sales -p salesdb1 < sales.sql

Share