MySQL Import Command

by Tweak on January 10, 2012
in Mysql

How do I import data stored in a “.sql” file (created by mysqldump command) under UNIX or Linux operating systems?

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

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

In this example import a file called sales.sql for salesdb1 user and sales db, enter:
$ mysql -u123tweak -p123password 123tweak < 123tweak.sql

If database 123tweakdoes not exists, first create it and than import it as follows:
$ mysql -u123tweak -p123password 123tweak -e 'create database 123tweak'
$ mysql -u123tweak -p123password 123tweak < 123tweak.sql

Share and Enjoy:
  • Add to favorites
  • Twitter
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Digg
  • del.icio.us
  • MySpace
  • Live
  • Yahoo! Buzz
  • PDF
  • email

Post a Comment