How to transfer mysql db from old host to new host

Today I had to transfer a mysql db from an old host to a new host. I used to do this with phpmyadmin and export the db and hope that it would work properly on upload. I did a quick google search today and came up with the line:

$ mysqldump -u username -p'password' old-db | ssh [email protected] mysql -u username -p'password' new-db

It took about one minute to transfer about 400mb of information. I am sure that there are other ways to do this, but it just worked for me perfectly.