in reply to Perl and MySql

Well, I guess one could always use DBD::mysql and write a dumper/importer, but why not just use mysqldump to dump the database, and import it on the other side?

If you set up an ssh tunnel, you can even do it in a pipe so you don't need the extra diskspace to store the dump on.

Replies are listed 'Best First'.
Re^2: Perl and MySql
by smiffy (Pilgrim) on Oct 17, 2008 at 21:12 UTC

    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
      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.