in reply to Re: Perl and MySql
in thread Perl and MySql

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

Replies are listed 'Best First'.
Re^3: Perl and MySql
by Anonymous Monk on Oct 19, 2008 at 14:05 UTC
    mysqldump --user=myuser --password=mypass mydatabase > mydb.sql

    You should be able to do the bzip at the same time as the dump: mysqldump --user=myuser --password=mypass mydatabase | bzip2 -- > mydb.sql That way, you don't use as much disk space.