Seconded.
There is absolutely no point in re-inventing the wheel - especially for a one-off job - when you can invoke mysqldump with a few seconds of typing.
mysqldump --user=myuser --password=mypass mydatabase > mydb.sql
I would prefer to actually see a file there rather than pipe through a tunnel - provided that I had the disc space.
If the resultant file is large, consider putting it through bzip2 before you move it. As the output of mysqldump is plain text (SQL), I have found that bzip2 can crunch it down enormously.
bzip2 mydb.sql
You might also want to take an MD5 sum of the resultant dump file to compare it with the file copied across the network. Better safe than sorry.
md5sum mydb.sql.bz2
|