Importing and Exporting MySQL Databases

June 19, 2013 | By

Importing and exporting MySQL databases in a Unix/Linux environment can be done easily with a single command. You can even choose to export the database’s structure or data only.

Exporting is done using the mysqldump program and importing is done using the MySQL command line client mysql.

mysqldump prints out the resulting SQL to standard output and mysql gets the SQL to execute from standard input. So you will use command line redirection with each.

Both programs also accept the same command line arguments. To pass the database credentials enter -u followed by the username and -p to prompt you for the password. And lastly the name of the database you want to import to or export from.

To import a database:

To export a database:

To export the database structure only:

To export the database data only:


If you found this post useful, I’d be very grateful if you’d help it spread by sharing it. Thank you!

Filed in: Linux, MySQL | Tags: ,

Comments (2)

  1. Thank-you…. this information is very useful, our website need MySQL databases, my site in MySQL databases error, but now is fixed. thanx.

  2. You’re welcome Jittu. Glad you found it useful.