You are viewing an old revision of this post, from April 11, 2014 @ 13:36:52. See below for differences between this version and the current revision.

MySQL Import File / Database Command

The mysqldump command line client is a backup program and it can be used to dump a database (backup database) or a collection of databases for backup or transfer to another SQL server. The dump typically contains SQL statements to create the table, populate it, or both. A common use of mysqldump is for making a backup of an entire database:

 
mysqldump db_name > backup-db_name.sql
mysqldump -u userNameHere db_name > backup-db_name.sql
mysqldump -u userNameHere -p db_name > backup-db_name.sql
 

You can import such a file using mysql command.

Syntax

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

 
mysql -u {DB-USER-NAME} -p {DB-NAME} < {db.file-name.sql}
mysql -u {DB-USER-NAME} -h {MySQL-SERVER-HOST-NAME} -p {DB-NAME} < {backup.db.file-name.sql}
mysql -e "source /path/to/backup-db.sql" db_name_here
mysql -u DB_USER_NAME -p -e "source /path/to/backup-db.sql" db_name_here
 

 

Revisions

  • April 11, 2014 @ 13:37:01 [Current Revision] by admin
  • April 11, 2014 @ 13:36:52 by admin

Revision Differences

There are no differences between the April 11, 2014 @ 13:36:52 revision and the current revision. (Maybe only post meta information was changed.)

No comments yet.

Leave a Reply