Create and Import dumpfile or SQL datafile into mysql database


Here are few commands to easily create and import MySQL data.

To create dumpfile:
mysqldump -u USER -p PASSWORD DATABASE > filename.sql

To import dumpfile:
mysql -u USER -p PASSWORD DATABASE < filename.sql

Export MySQL database structure only:
mysqldump -u USER -p PASSWORD --no-data DATABASE > filename.sql

Export data of MySQL database only:
mysqldump -u USER -p PASSWORD --no-create-info DATABASE > filename.sql

To create dumpfile of all databases:
mysqldump -u USER -p PASSWORD --all-databases > filename.sql

To import dumpfile when either database name is not known or dump has database info:
mysql -u USER -p PASSWORD < filename.sql

USER : database username
PASSWORD : password
DATABASE : database name to which datafile is to be imported

Advertisements

1 thought on “Create and Import dumpfile or SQL datafile into mysql database”

  1. Thanks for another excellent post. The place else could anybody get that type of info in such an ideal way of writing? I have a presentation next week, and I am at the look for such information.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s