Ubuntu: Import a SQL Dump into MySQL CodeUnit 09 JAN 2011

The quickest way to import a properly generated SQL dump containing structure and table definitions plus data into a MySQL database is to simply pipe the file directly to the powerful mysql command function via a terminal window.

The command would look something like this:

mysql --verbose -u username -ppassword mydatabase < sqldump.sql

Although the --verbose switch is technically not needed, it does make it easier to follow the progress of the resulting import. The -u and -p switches indicates the account with which to access the MySQL serve (Note the lack of space between -p and the password). Finally "mydatabase" should be replaced with the name of the database to effect.

Nifty.

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.